正则表达式负前瞻 [英] Regex negative lookahead
本文介绍了正则表达式负前瞻的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要修改此正则表达式
I need to modify this regex
href=\"(.*)\"
与之匹配的...
href="./pothole_locator_map.aspx?lang=en-gb&lat=53.153977&lng=-3.533306"
不符合此条件...
href="./pothole_locator_map.aspx?lang=en-gb&lat=53.153977&lng=-3.533306&returnurl=AbandonedVehicles.aspx"
尝试过这个,但是没有运气
Tried this, but with no luck
href=\"(.*)\"(?!&returnurl=AbandonedVehicles.aspx)
任何帮助将不胜感激.
谢谢,
推荐答案
在匹配使用字符串之前,应将先行符放在首位
Lookaheads should be placed before the string is consumed by matching, i.e.
href=\"(?!.*&returnurl=AbandonedVehicles\.aspx)(.*)\"
这篇关于正则表达式负前瞻的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文