One easy way to exclude text from a match is negative lookbehind:
w+b(?<!bfox)
But not all regex flavors support negative lookbehind. And those that do typically have severe restrictions on the lookbehind, eg, it must be a simple fixed-length expression. To avoid incompatibility, we can restate our solution using negative lookahead:
(?!foxb)bw+
Read full article from Excluding Matches With Regular Expressions
No comments:
Post a Comment