I would like to have a regex which identifies all words of the form: xxxxBlah
but to ignore a specific case of: SpecialBlah
Is there any simple way to express this as a regular expression?
I would like to have a regex which identifies all words of the form: xxxxBlah
but to ignore a specific case of: SpecialBlah
Is there any simple way to express this as a regular expression?
Depending on the larguage/IDE/tool you're using, this should work:
\w+(?<!Special)Blah
It uses a negative look-behind. So it finds any word-characters before "Blah", as long as it's not "Special".
Others have provided alternatives when a negative lookbehind is not possible, such as in JavaScript.
Please consider bookmarking the Stack Overflow Regular Expressions FAQ for future reference.