Regular Expressions Part IX: Plus Signs +

November 9, 2006

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