Negate match for word in the beginning of string i

2019-07-14 02:40发布

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条回答
Emotional °昔
2楼-- · 2019-07-14 03:13

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.

查看更多
登录 后发表回答