AdWords is now Google Ads. Our new name reflects the full range of advertising options we offer across Search, Display, YouTube, and more. Learn more

Analytics
4.6K members online now
4.6K members online now
Learn how to set up goals and Ecommerce tracking, verify accuracy of attribution traffic sources, and discuss funnel visualization, Multi-Channel Funnels, the Goal Flow Report, and Enhanced Ecommerce
 
Guide Me
star_border
Reply

Regex combination of 2 urls: difference 1 word in between

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

I have 2 regex expressions that I need to combine into one. I'm looking for 1 regex that will validate both URLs below. 

 

1st 

URL: cart/auto/done/?tx=99445068UN007545N&st=Completed&amt=297.00&cc=USD&cm=&item_number= 

Regex: cart/\w+/done.* 

 

2nd 

/cart/done/?tx=5CW532565J668892C&st=Completed&amt=249.01&cc=USD&cm=&item_number= 

Regex: cart/done.* 

 

Any ideas?

2 Expert replyverified_user

Re: Regex combination of 2 urls: difference 1 word in between

Top Contributor
# 2
Top Contributor
Just put a vertical bar ( OR operator ) between them:
cart/\w+/done.*|cart/done.*
Mike Sullivan, Google Analytics Top Contributor
Was my response helpful? If yes, please mark it as the ‘Best Answer.’ Learn how here.

Re: Regex combination of 2 urls: difference 1 word in between

[ Edited ]
Top Contributor
# 3
Top Contributor

Hi Javier,

You can try ^\/(cart.+done)(\W|$)

It assumes both URLs start with "/cart" (your 1st URL does not have a leading slash)

 

You can test the regex using http://www.analyticsmarket.com/freetools/regex-tester

Let me know if it works.


Arnold Majlath, Google Analytics Top Contributor
Was my response helpful? If yes, please accept it as solution.
Circle Me On Google+ | Visit me @ Redfly Digital