4.1K members online now
Ask questions about filter set-up and issues with using filters in Google Analytics reports
 
Guide Me
star_border
Reply

Regex??

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Can anyone please help me with a regex for the following URLs:

 

/sv/sok/lagenheter/11771/halmstad/sven-jonsons-gata-17                                < Match
/sv/sok/lagenheter/11497/vasterhaninge/bjornvagen-10-e/bilder                      < No match
/sv/sok/lagenheter/12222/halmstad/jarnvagsgatan-4                                        < Match
/sv/sok/lagenheter/11796/skarholmen/algrytevagen-27b/karta                         < No match
/sv/sok/lagenheter/11796/skarholmen/algrytevagen-27b/pdf                            < No match

 

So basically I want to skip the URLs that have the last slash with the following subcategory.

 

Best,

Mark

2 Expert replyverified_user

Re: Regex??

Rising Star
# 2
Rising Star
Do URLs end with a forward slash? If they do, try the below and see if it works.

^/sv/sok/lagenheter/[1-9]{5}/(.*)/(.*)/$

Re: Regex??

Top Contributor
# 3
Top Contributor
Hi,

Please check also this one:

^/sv/sok/lagenheter/[1-9]{5}/[a-z]+/[a-z0-9-]+$

I tested it on your paths using the regex tester: http://www.analyticsmarket.com/freetools/regex-tester

Arnold Majlath, Google Analytics Top Contributor
Circle Me On Google+ | Visit me @ Redfly Digital

Re: Regex??

Visitor ✭ ✭ ✭
# 4
Visitor ✭ ✭ ✭
Hi!

Basically I won't to remove URLs that ending with /bilder, /karta, /pdf since they are subcategory pages from the result. Is that possible?

Best,

Marked as Best Answer.
Solution
Accepted by topic author Akelius A
September 2016

Re: Regex??

Top Contributor
# 5
Top Contributor
Hi,

My regex above will match the paths without the ending subdirectory so if you use it for an exclude filter it will keep the paths with the subdirectories.

Let me know if you have more questions.

Arnold Majlath, Google Analytics Top Contributor
Circle Me On Google+ | Visit me @ Redfly Digital