Google Analytics & Tag Manager RegEx Guide

RegEx or Regular Expression are a string describing a specific text pattern. They are helpful when defining goals and filters in Google Analytics or Triggers in Google Tag Manager.

The below table outlines the RegEx characters commonly used in Google Analytics and Google Tag Manager (GTM).

RegExMeaningExample
|ora|b – matches a or b
.any single charactera.c – matches abc, acc, adc, …
?zero or one previous charactergoo?gle – matches gogle and google, but not gooogle
*zero or more previous charactersgoo*gle – matches gogle, google, gooogle
+one or more previous charactersgoo+gle – matches google, gooogle, but not gogle
^start of the string^apple – matches apple juice, but not pineapple
$end of the stingapple$ – matches pineapple, but not apple juice
[]list of items to match to[a-z] – matches any lowercase letter from a to z
b2[cb] – matches b2c, b2b
()group elementsJan(uary)? – matches Jan, January
January?  – matches Januar, January
{}define character count , – matches any two number string  from 01 to 99
[0-9] – matches any number string from 1-999
 \treat RegEx characters like normal characters\? – matches a question mark, not zero or one character