Upcoming LunaMetrics Seminars
Washington DC, Dec 1-5 Los Angeles - Anaheim, Dec 8-12 Pittsburgh, Jan 12-16 Boston, Jan 12-16

Regular Expressions Part IX: Plus signs +





This is part nine of a multi-part series I am doing to make Regular Expressions (“RegEx”) more understandable for users of Google Analytics. I am learning and teaching at the same time.

Today, I am writing about the plus sign, +. Here is how GA defines the plus sign:

+ Match one or more of the previous items

This probably seems perfectly reasonable to Google and other old hands at Regular Expressions, because they already know how to define “the Previous Items.” But I didn’t and had to figure it out.

regular-expressions

The simplest meaning of “Previous Items” is “previous character.” So, I could look for my name in my Google Analytics search terms by typing this into the “quick filter” box: Rob+in. That will return Robin or Robbin, and for that matter, Robbbbin. It’s actually pretty useful, since I get a lot of searches like that, and often want to filter them out.

Alternatively, you can build a list of Previous Items by using square brackets. Like this: [abc]+ This will return a, ab, cab, c, b, bbbb and the like. This seems a little strange, but in fact, if you read the interpretation (“match one or more of the previous items”), you’ll notice there isn’t anything about the previous items being in a specific order.

However — I couldn’t think of any way to use square brackets with a plus sign that I couldn’t achieve with other Regular Expressions. So I wrote my tutor in Australia, Steve. The best example he had was searching for a space. Thus: if I wanted to know how many people type in web site or web site or even web site, I could create web[ ]+site for my Regular Expression.

If you have any other great uses of square brackets and plus signs for Google Analytics, please share them.

Backslashes \
Dots .
Carats ^
Dollars signs $
Question marks ?
Pipes |
Parentheses ()
Square brackets []and dashes -
Plus signs +
Stars *
Regular Expressions for Google Analytics: Now let’s Practice
Bad Greed
RegEx and Good Greed
{Braces}
Minimal Matching
Lookahead

Robbin

Robbin Steif

About Robbin Steif

Our owner and CEO, Robbin Steif, started LunaMetrics ten years ago. She is a graduate of Harvard College and the Harvard Business School, and has served on the Board of Directors for the Digital Analytics Association. Robbin is a recent winner of a BusinessWomen First award, as well as a Diamond Award for business leadership.

http://www.lunametrics.com/blog/2006/11/09/regular-expressions-part-ix-plus-signs/

5 Responses to “Regular Expressions Part IX: Plus signs +”

skr325 says:

Great posts. Now I just need to test everything. Do you know a way to test RegEx in the updated GA interface? I’ve tried but the filter is a bit easier (which also means almost anything gives results).

Hey, one more quick thing — to be found by the many others looking for your posts you may want to add “Google Analytics” to the beginning of the article & page titles.

Thanks again for taking the time to dumb this stuff down for us folks who’ve never written a line of code!

Robbin says:

Hi Steve. I confess, I am not sure what you mean by testing RegEx in the updated GA interface. Did you mean that the filter that they provide has “bigger holes” and anything gives results, i.e. easier than the old one? I actually didn’t find that, but I could be wrong. Tell me more what you mean by that… you know, the RegExen are very greedy, so they are supposed to return the most results possible unless you constrain your search severely.

I test all important RegEx expressions with the Epikone RegEx tester:
http://www.epikone.com/tools/regular-expression-filter-tester

skr325 says:

I like to test my expressions in Google Analytics (outside of goals), however the updated analytics seems to have changed the expression logic and the filters don’t work quite the same way. Once I lose access to the old reports, I fear that I will lose the ability to test against my own data set. Epikone is great but it only gets me so far…maybe if I get better at RegEx it will be more helpful..hmm.

Hey, I found this tonight and thought it may be of use: http://www.ilovejackdaniels.com/regular_expressions_cheat_sheet.pdf

Robbin says:

Show me. I am dying to see. I promise I will get the info to Google (they probably read this anyway.) Use Dylan Lewis’ new web analytics wiki, the Google Analytics are open to everyone, here is the userid and password.

Excellent site. A lot of useful info here. I’m sending it to several pals ans also sharing in delicious. And certainly, thank you to your effort!