13.07.2015 Views

ebook on regular expressions for Google Analytics - LunaMetrics

ebook on regular expressions for Google Analytics - LunaMetrics

ebook on regular expressions for Google Analytics - LunaMetrics

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

get startedThe b AckslAshI always encourage people to start their“RegEx career” by learning the characters, and the best <strong>on</strong>eto start with is the backslash. A backslash is different fromall the other characters, as you will see. It provides a bridgebetween Regular Expressi<strong>on</strong>s and plain text.A backslash “escapes” a character. What does “escape”mean? It means that it turns a Regular Expressi<strong>on</strong> characterinto plain text. If that doesn’t make sense to you yet, hold <strong>on</strong>– I have a few examples coming.Perhaps /folder?pid=123 is your goal page. The problemwe have is that the questi<strong>on</strong> mark already has another use inRegular Expressi<strong>on</strong>s – but we need <strong>for</strong> it to be an ordinaryquesti<strong>on</strong> mark. (We need it to be plain text.)We can do it like this:/folder\?pid=123Notice how there is a backslash in fr<strong>on</strong>t of the questi<strong>on</strong>mark – it turns it into a plain questi<strong>on</strong> mark.Example Alert: Now, when we are creating a <strong>Google</strong><strong>Analytics</strong> search and replace filter <strong>for</strong> the page above, wecan use that backslash and know that GA understands weare looking to match to a real questi<strong>on</strong> mark, like so:\Why are backslashesabout getting started?1. You will use them more than any other RegEx character.2. They turn special RegEx charactersinto everyday, plain characters.7

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!