Reputation: 28475
I have this RegEx:
(?<=\s)(?i)bananas?(\*(x|u|z))?(?=<VNW)
Which should find hits such as:
banana*x
bananas
Bananas*z
only when preceded by a space (white space character is fine I guess? Is there a shorthand for only a space?) and followed by <VNW
.
However, when testing with an online regex tester, this does not behave as expected. Try for instance bananas*z<VNW
. It won't be a match. However, when adding the x modifier, it seems to work fine! Change the RegEx to:
(?<=\s)(?ix)bananas?(\*(x|u|z))?(?=<VNW)
And it ought to work fine. But I don't get why? There's not a single space in my query, nor is there in the regex. What's going on?
Upvotes: 0
Views: 32
Reputation: 26667
The regex is fine expect that you have an extra space at the end.
Remove that and it will work fine
(?<=\s)(?i)bananas?(\*(x|u|z))?(?=<VNW)
Upvotes: 2