-2

In regex you can say what characters to negate. I need to find expressions not having exact words. For example find expressions having "foo" not followed by "bar" or "baz". So "foo bar" or "foo baz" is not allowed while "foo joo" is ok.

navid
  • 51
  • 1
  • 4

1 Answers1

0

The following regex can be used to achieve it:

foo\s(?!bar)(?!baz)
navid
  • 51
  • 1
  • 4