开发者

Regex negative lookahead

开发者 https://www.devze.com 2022-12-27 13:44 出处:网络
I need to modify this regex href=\\\"(.*)\\\" which matches this... href=\"./pothole_locator_map.aspx?lang=en-gb&开发者_如何学运维lat=53.153977&lng=-3.533306\"

I need to modify this regex

href=\"(.*)\"

which matches this...

href="./pothole_locator_map.aspx?lang=en-gb&开发者_如何学运维lat=53.153977&lng=-3.533306"

To NOT match this...

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)

Any help would be much appreciated.

Thanks, Al.


Lookaheads should be placed before the string is consumed by matching, i.e.

href=\"(?!.*&returnurl=AbandonedVehicles\.aspx)(.*)\"


href="(?!.*returnurl=AbandonedVehicles\.aspx)(.*)"
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号