Regex To Match Anything But One Or More Words

A regular expression which can match anything except one or more words in a string. It is a handy one if you want to skip some words in your index file.

/^(?!regex$|pattern$).*/

Matches:

  • I like regex pattern.
  • I Like pattern regex.
  • I Like regexpattern.

Non-matches:

  • regex
  • pattern

See Also: