-2

I have found from another post that this regex: ^(?!.bar).$ mathces everything that does not containing the word bar.

My question is, what do I add to this in order to recognize sentences that start also from a specific word, say 'test'. For example:

test word1 word2 
testasdsd 

and so on.

I have tried adding the word 'test' to the beggining of the above regex but it doesnt work.How can I do it?

Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563

1 Answers1

1

This works for you:

^test(?!.*bar)

ruohola
  • 21,987
  • 6
  • 62
  • 97