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.9K members online now
4.9K members online now
Ask questions about filter set-up and issues with using filters in Google Analytics reports
 
Guide Me
star_border
Reply

Regular Expression - excluding strings

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

I'm trying to write a regex that will filter out everything except the bold lines

 

/user/login

/users/username
/user/login?destination=node/100016764
/user/password
/user/password?name=xxxxx

/user/register
/user/register?cat_name=stuff

 

This is the regex I've created and it works in the test site that I use (http://regexr.com/)

 

\/user(|s)\/(?!login$|register$|password$).*

 

However when I put it into the filter of the report I've created it says:

Invalid regular expression

Your data request includes an invalid regular expression.

 

Does anyone have any ideas why it doesn't work in the filter for GA reporting but still works as a regex?

1 Expert replyverified_user
1 ACCEPTED SOLUTION

Accepted Solutions
Marked as Best Answer.
Solution
Accepted by topic author Simon D
March 2016

Re: Regular Expression - excluding strings

[ Edited ]
Top Contributor
# 2
Top Contributor

Hi Simon :-)
Negative lookaheads unfortunately are not permitted.

Try the following in an include filter
^/users?/(login|password|register)$

Use the carat ^ at the beginning of the line if this is where the request uri begins
eg if the urls were www.somesite.com/users/login
dont use the carat if the part of the url you are trying to match is somewhere else in the url
eg www.somesite.com/someotherdirectoryhere/users/login

 

The ? means the character immediately before it is optional so users? will match user or users

And the $ at the end states this is where matching ends

Bronwyn Vourtis, Google Analytics Top Contributor
Was my response helpful? If yes, please mark it as the ‘Best Answer.’ Learn how here

View solution in original post

Marked as Best Answer.
Solution
Accepted by topic author Simon D
March 2016

Re: Regular Expression - excluding strings

[ Edited ]
Top Contributor
# 2
Top Contributor

Hi Simon :-)
Negative lookaheads unfortunately are not permitted.

Try the following in an include filter
^/users?/(login|password|register)$

Use the carat ^ at the beginning of the line if this is where the request uri begins
eg if the urls were www.somesite.com/users/login
dont use the carat if the part of the url you are trying to match is somewhere else in the url
eg www.somesite.com/someotherdirectoryhere/users/login

 

The ? means the character immediately before it is optional so users? will match user or users

And the $ at the end states this is where matching ends

Bronwyn Vourtis, Google Analytics Top Contributor
Was my response helpful? If yes, please mark it as the ‘Best Answer.’ Learn how here

Re: Regular Expression - excluding strings

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭

Thanks Bronwyn.

 

Your solution certainly assisted.  Thanks heaps for the help. Smiley Very Happy

Re: Regular Expression - excluding strings

Top Contributor
# 4
Top Contributor
You're welcome Simon :-)

If you need further help or have other questions, pls post back

Cheers
Bronwyn :-)
Bronwyn Vourtis, Google Analytics Top Contributor
Was my response helpful? If yes, please mark it as the ‘Best Answer.’ Learn how here