0

I am trying to exclude the word ‘define’ without excluding other forms of the word like ‘defined’ or ‘defining’ but the below mentioned regex doesn’t work. Help.

Regex :

^((?!define).)*$

kaushik3993
  • 105
  • 1
  • 3
  • 10

1 Answers1

1

Use word boundaries around the word define:

^((?!\bdefine\b).)*$

You could also write this pattern as:

^(?!.*\bdefine\b).*$

Demo

Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360