在RE2语法中否定匹配字符串开头的单词? [英] Negate match for word in the beginning of string in RE2 syntax?

查看:328
本文介绍了在RE2语法中否定匹配字符串开头的单词?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有以下字符串:

  • 发送邮件至
  • 电话:+358123456
  • http://www.google.fi
  • mailto:foo@bar.fi
  • 你好世界
  • 电话
  • 大象
  • 一分钱
  • 链接
  • 猫头鹰
  • mail to
  • tel:+358123456
  • http://www.google.fi
  • mailto:foo@bar.fi
  • hello world
  • telephone
  • elephant
  • penny
  • link
  • owl

如何用RE2语法仅查找不以'tel:','http://'和'mailto:'开头的字符串?

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:)]

RE2语法不支持否定的后向/超前.

edit: RE2 syntax does not support negative lookbehind/lookahead.

推荐答案

对于我所知道的RE2缺乏负面的后顾之忧,没有任何替代解决方案.

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.

这篇关于在RE2语法中否定匹配字符串开头的单词?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆