I have to search a string for a few words eg, dog, cat, lion but I want regex to fail if lizard is found in the string even if it contains cat, dog or lion.
ismatch(pass) "dog|cat|lion" "This is not your average cat!"
ismatch (fail) [my regex statement] "This is not your average cat! It's a lizard."
[my regex statement] – here the regex statement is unknown, can you please help me to write this statement?
Word spaces and boundaries or lower/uppercase is not a concern. I run the string through
Replace(" ", "").Trim(" ").ToLower
before handover to Regex.
Try this using negative lookahead and negative look behind
If you use the Regex option ignore case you don’t need to call tolower. You can specify it by adding
(?i)to the beginning of the regex string.After comment by js_dudley here is a way to build the string up