java regular expression - match all strings except few strings
I have these strings in an array and I want to iterate this array and find those who match (one line per match check).
The thing is, I can't find the right regex.Bird
Cat
Dog
Fish
CatDog
DogCat
Currently, with RegexBuddy (damn nice software!!), I have this regex:
(?!Cat\b)\b\w+
I want to add the "Dog" to it so in one regex match try I'll get a match result, you know, like an OR operator.
I want it to c开发者_JS百科heck if "Cat" or "Dog" or "Fish" is there in one go.Any idea?
Try the following:
\b(?!(?:Bird|Cat|Dog|Fish|CatDog|DogCat)\b)\w+
The |
character is an OR operator in regex.
精彩评论