Show Menu

Google Analytics Regular Expressions Cheat Sheet by

A list of Regular Expression functionality supported by Google Analytics


Start of line
End of line

Character Classes

White space character
Non-white space character
Digit character
Non-digit character
Non-word (e.g. punctu­ation, spaces)

Metach­ara­cters (must be escaped)


GA Filter group accessors

Access group x in field A (e.g. $A1)
Access group x in field B (e.g. $B1)


Zero or more (greedy)
Zero or more (lazy)
One or more (greedy)
One or more (lazy)
Zero or one (greedy)
Zero or one (lazy)
Exactly X (e.g. 3)
X or more, (e.g. 3)
{X, Y}
Between X and Y (e.g. 3 and 5) (lazy)

Ranges and Groups

Any character
a or b (case sensitive)
Group, e.g. (keyword)
Passive group, e.g. (?:key­word)
Range (a or b or c)
Negative range (not a or b or c)
Uppercase letter between A and Z
Lowercase letter between a and z
Digit between 0 and 7

Sample Patterns

Any page URLs starting with /direc­tory/

Brand term with or without whitespace between words

Key phrases beginning with 'brand' and the second word not starting with c or f

URLs ending in '.aspx'

"OR­DER­-" followed by a six digit ID

Value of 'utm' querys­tring parameter


Great cheat sheet, Jay, especially the sample patterns!

Jay Taylor Jay Taylor, 18:10 11 Feb 12

Thanks Dave! Obviously it's based heavily on your main RE one, I'm really hoping Google will add support for assertions in the future, would make life so much easier!

Nice cheat sheet Jay

I don't think you need this one:

as just (brand) will work, no? That is, (brand) will match:
"brandterm", and "brand term"

Excellent cheat sheet Jay, really helpful.

This is really helpful. Thank you Jay. Just the kind of resource we need.

Good stuff Jay! Thanks for sharing.

thanks much Jay!!

Great information, really awesome..

Cant thank you enough for this amazing resource!

I do have a file name LIKE maxfile_[A-Z]_[0-9]{6} and I want to use a wild card like ^maxfile_ but it does not work

Hi guys,

Just a short question on using the right regular expression. I want to create a funnel which has to gather information on different URL's. The one thing that all the URLs have in common is their last part. For example, i want to include al these URL's in one step of a funnel:


> They all have the same last part; 'step4'. Which regulare expression do i have to use to collect the data of all these different pages?

Hope you can help me!


user this regex:


That would be

What about "#" ?
i need to create the rule that only fires up on deep links.
Any help would be appreciated.

Thank you so much for the cheat sheet!

I have a goal that could encompass any number after /offer. Would this be correct?



+ Información y Documentación en Español

I've have an question i have the following link:


now in my google goals he's only showing the visits

(?:brand) containing brand

but i want to exclude the word brand instead of showing it

how can i fix that?

This is cool

Im looking to do a GA filter to filter out several versions of internet explorer

Currently doing One at a time

and have 9\.11 as the pattern

is that correct?

hi! I have page

i need to set a goal with "buy" or "b6b6457d__-1936669385__" how to do that? thanks

hello I need your help, I have these ejm for goals:

Use regular expression:

But I still do Not report goals at analytics, it may be problem with the "#" ?


Is this sheet still valid (2015 November)? The original post is from 2012.

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          Regular Expressions Cheat Sheet
          Google Analytics UTM Parameters (v2) Cheat Sheet
          Google Universal Analytics URL Collect Parameters Cheat Sheet

          More Cheat Sheets by Jay Taylor

          Google Analytics UTM Parameters (v2) Cheat Sheet
          Google Analytics Cookies (v2) Cheat Sheet