Regex negative lookahead

2019-06-23 04:03发布

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.

2条回答
迷人小祖宗
2楼-- · 2019-06-23 04:31

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

href=\"(?!.*&returnurl=AbandonedVehicles\.aspx)(.*)\"
查看更多
叼着烟拽天下
3楼-- · 2019-06-23 04:33
href="(?!.*returnurl=AbandonedVehicles\.aspx)(.*)"
查看更多
登录 后发表回答