Google Analytics Regular Expressions Cheat Sheet
by
Jay Taylor (Jay Taylor)
via
Anchors
Quanti f iers
Sample Patterns
^
Start of line
*
Zero or more (greedy)
^/di r ec t or y /(.*)
Any page URLs starting with /direc t ory/
$
End of line
*?
Zero or more (lazy)
(bra n d \ s*? t erm)
+
One or more (greedy)
Brand term with or without whitespace between
Character Classes
+?
One or more (lazy)
words
\s
White space character
^br a nd \ s+ [ ^cf]
?
Zero or one (greedy)
Key phrases beginning with 'brand' and the
\S
Non-white space character
??
Zero or one (lazy)
second word not starting with c or f
\d
Digit character
{X}
Exactly X (e.g. 3)
\.as p x$
\D
Non-digit character
{X,}
X or more, (e.g. 3)
URLs ending in '.aspx'
\w
Word
ORDE R \- \ d{6}
{X, Y}
Between X and Y (e.g. 3 and 5) (lazy)
"OR D ER - " followed by a six digit ID
\W
Non-word (e.g. punctu a tion, spaces)
(?: \ ?|&)u t m= ( [^ & $ ] +)
Ranges and Groups
Value of 'utm' querys t ring parameter
Metach a ra c ters (must be escaped)
.
Any character
^
[
]
(a|b)
a or b (case sensitive)
$
(
)
(...)
Group, e.g. (keyword)
.
{
}
(?:...)
Passive group, e.g. (?:key w ord)
*
+
?
[abc]
Range (a or b or c)
\
|
-
[^abc]
Negative range (not a or b or c)
[A-Z]
Uppercase letter between A and Z
GA Filter group accessors
[a-z]
Lowercase letter between a and z
$Ax
Access group x in field A (e.g. $A1)
[0-7]
Digit between 0 and 7
$Bx
Access group x in field B (e.g. $B1)
By Jay Taylor (Jay Taylor)
Published 10th February, 2012.
Sponsored by
Last updated 1st June, 2014.
Measure your website readability!
Page 1 of 1.