Regular Expressions Part I: Escaping with a Backslash/
August 13, 2006
What are Google Analytics’ “Regular” Expressions?
This was the question that I asked in August 2006. Although this post is ostensibly from August, I am actually rewriting it in October. Now that I understand Regular Expressions for Google Analytics, I want to explain them in the easiest language possible (so I had to go back and rewrite.)
The most basic expression is the backslash. Google Analytics ascribes this meaning to it:
escape any of the above
What they mean is, you can use a backslash to turn any special character into a not-so-special character. Google (and everyone else who talks about Regular Expressions) makes this hard by using the word “escape,” when they merely mean, use a backslash to take the magic out of a special character and make it an everyday character.
Although the backslash can be used with any special character, I see it used most often with a dot. This is because a dot is both a special character (see Part II), and one that is used with the Internet all the time (Example: www.myspace.com — we see it there twice.) On the Internet (and so, with Google Analytics) we almost always are using dots as regular dots and so need a backslash to keep it as a mere dot. Here’s an example: mysite.com and here’s another one (this time, an IP address): 188.8.131.52
Many thanks to my tutor in Australia, Steve. With his help, help from Justin Cutroni, and many hours of reading and rereading the Wikipedia page on Regular Expressions (I won’t even link there, it is so difficult), I learned Regular Expressions. Very late comment: This started as a mere question for me. This ended with a seventeen part series.
Dollars signs $
Question marks ?
Square brackets and dashes –
Plus signs +
Regular Expressions for Google Analytics: Now let’s Practice
RegEx and Good Greed