正则表达式匹配一个字符串,该字符串后跟另一个字符串,但不捕获后者 [英] regular expression matching a string that is followed with another string without capturing the latter

查看:253
本文介绍了正则表达式匹配一个字符串,该字符串后跟另一个字符串,但不捕获后者的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有能力使前瞻性断言不被捕获? bar(?:!foo)bar(?!:foo)之类的东西不起作用(Python).

Is there an ability to make a lookahead assertion non-capturing? Things like bar(?:!foo) and bar(?!:foo) do not work (Python).

推荐答案

如果您这样做bar(?=ber) 在理发店"上,酒吧"是匹配的,但没有捕获到理发店".

If you do bar(?=ber) on "barber", "bar" is matched, but "ber" is not captured.

这篇关于正则表达式匹配一个字符串,该字符串后跟另一个字符串,但不捕获后者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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