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

Category: Strings

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:

Rate This Regex
Sending
User Review
0 (0 votes)

Expression Flags

Flags Description
i Ignore case sensitive.
g Allows global search.
m Allows multiline search.