Reputation: 39
I need help to do this regex. The sentence can't be less than 4 letters, and it can't match any of these word (test1,test2 and test3)
I know how to do each one separately but not together.
First condition ^.{4,}$
Second condition ^((?!test1|test2|test3).)*$
How to do both so that:-
Thanks in advance
Upvotes: 2
Views: 130
Reputation: 77904
Try this one:
(?=^.{4,}$)(^((?!test1|test2|test3).)*$)
Or:
(?=^.{4,}$)(^((?!test(1|2|3)).)*$)
Or:
(?=^.{4,}$)(^((?!test[1-3]).)*$)
Upvotes: 5