Negate match for word in the beginning of string in RE2 syntax?

ぐ巨炮叔叔 提交于 2019-12-02 05:37:46

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!