Regex To Match A line That Doesn’t Contain A Specific Word

A regular expression to match a line that doesn’t contain a word you specify.

/^((?!regex).)*$/s

Matches:

  • I’m regex pattern.com

Non-matches:

  • I’m regexpattern.com
  • I’m regex pattern.com

See Also: