Regex to match anything (including the empty string) except a specific given string.
Posted
by dreeves
on Stack Overflow
See other posts from Stack Overflow
or by dreeves
Published on 2010-05-14T20:08:25Z
Indexed on
2010/05/14
20:14 UTC
Read the original article
Hit count: 170
regex
I'd like to test whether a string contains "Kansas"
followed by anything other than " State"
.
Examples:
"I am from Kansas" true
"Kansas State is great" false
"Kansas is a state" true
"Kansas Kansas State" true
"KansasState" true
(For my immediate purposes this should work with mysql's REGEXP but if there's a more elegant way using PCRE, I'd like to see that too.)
© Stack Overflow or respective owner