cphill
cphill

Reputation: 5914

Regex exclude certain strings before targeted URL path

I am running into an issue where I can't seem to exclude certan strings like "registration and login" from my regex. I am trying to get URLs that contain /bag/order/orderinfo.aspx and anything after that path, but the issue is that it is picking up on certain url referrer paths and additional parameters that do not lead to the correct pages I am trying to use. I tried [^registration|login] before the /Bookbag, but that didn't do anything

Here is my regex:

\/Bookbag\/order\/OrderInfo\.aspx.*

Currently picking up on all of the following URLs, but I only want to include these three paths:

http://test.com/bag/order/orderinfo.aspx
http://test.com/bag/order/orderinfo.aspx?empty=0&txttarget=
http://test.com/bag/order/orderinfo.aspx?txttarget=

Not these links, which are currently being picked up by my current RegEx setup:

urlreferrer=http://test.com/catalog/&returl=http://test.com/bag/order/orderinfo.aspx&cancelurl=http://test.com/catalog/login

http://test.com/bag/registration/registrationcheckout_aboutyou.aspx?type=checkoutwithoutreg&email=test&txttarget=http://www.test.com/bag/order/ordercourseinfo.aspx\

Upvotes: 1

Views: 897

Answers (1)

anubhava
anubhava

Reputation: 785156

You can use negative lookahead regex like this:

/^(?!.*(registration|login)).*?\/bag\/order\/OrderInfo\.aspx.*$/gmi

Javascript RegEx Demo

Upvotes: 1

Related Questions