问题
Let's say that I have following strings:
- mail to
- tel:+358123456
- http://www.google.fi
- mailto:foo@bar.fi
- hello world
- telephone
- elephant
- penny
- link
- owl
How can I find only strings that do not start with 'tel:', 'http://' and 'mailto:' in RE2 syntax?
I've tried following with following syntax, but it filters out all of them:
[^(https?://|tel:|mailto:)]
edit: RE2 syntax does not support negative lookbehind/lookahead.
回答1:
There is no drop-in workaround for the lack of negative lookbehind on RE2 that I know of.
Why don't you match on strings that do start with those keywords instead? Then you can dismiss those.
来源:https://stackoverflow.com/questions/32844945/negate-match-for-word-in-the-beginning-of-string-in-re2-syntax