问题
I want to match a URL containing both "foo" and "bar" but not "bar=0".
I'm trying to do this in Google Analytics and it doesn't support lookahead expressions.
So I am matching urls containing both "foo" and "bar" with this expression (foo.+bar)
but how do I negate urls with "bar=0"?
回答1:
You can use this regex:
\bfoo\b.+\bbar\b(?:$|=[^0]|[^=])
Live Demo: http://www.rubular.com/r/marUIfFzAz
回答2:
foo.+bar[^\=]
for this to make any sense, please post a example of a url you are trying to validate
来源:https://stackoverflow.com/questions/18332696/regex-to-include-and-exclude-without-lookahead