I am using Regex.IsMatch() to evaluate a list of words.
The Regex should return true if the following strings are evaluated:
-hellotest
-helloabc
-abchello
and the Regex should return false if the following strings are evaluated:
-helloworld
-worldtest
-abcworld
Basically I want it to return true if the word "hello" is found in the string and if the word "world" is not found in the string.
What’s the Regex to produce such result?
Use the expression
(?<!prefix)posis a negative lookaround.posis only matched, if it is not preceeeded byprefixpos(?!suffix)is only matched if it is not succeeded bysuffix