Regular Expressions
So You Want to Learn Regular Expressions? Part 7: Examples: IP Addresses
Submitted by Steve on November 9, 2008 - 7:05pm.The full list of Regular Expression Articles I've done:
In this article I'm going to take you a little through the method and madness of creating regular expressions for filtering or identifying IP Addresses and Ranges.
It will demonstrate and combine the concepts explored in previous articles. Hopefully cast some illumination on the method of solving Regular Expression problems, and highly coincidentally, show how to filter your corporate network from your Google Analytics stats.
So You Want to Learn Regular Expressions? Part 6: Errr... Or...
Submitted by Steve on November 9, 2008 - 7:02pm.The full list of Regular Expression Articles I've done:
In the previous article with our box of chocolates, we used a method for choosing between one or more of several, more or less random, characters. [abc]+ for example.
But a common task in any web analytics is to be able to choose between several different items and treat them identically.
eg Images: gif, jpg, png
or, Pages: htm, html, cfm, php, asp and so on.
Or to put the first case pretty bluntly in English, we want "gif" or "jpg" or "png" at the end of a file name request.
So You Want to Learn Regular Expressions? Part 5: Just Like a Box of Chocolates
Submitted by Steve on November 9, 2008 - 6:59pm.The full list of Regular Expression Articles I've done:
- What and How? - Wherein we look at What a Regular Expression actually is, and How they basically work.
- Wild Cards - A starting look at the use of wildcards. Ways to find lots of stuff.
- Positioning - Finding stuff is good. Being able to specify where stuff may be found is better.
- More Wild Cards - More ways to find lots of stuff.
- Just Like a Box of Chocolates - The Ultimate Analogy. Single choices from between Square Brackets.
- Choices, Choices, Choices.... - Exposing bigger choices: Err... Or.
- Filtering IP Addresses - Wherein I bore the reader to tears explaining how to RegEx for IP Addresses.
"Just Like a Box of Chocolates"?? Yeah. Pretty cool analogy isn't it! Just wait! 
I hope we're all familiar with the principle of being offered to pick a choccy from a box of Chocolates. Pick one and one only. But any one of the myriad of choices arrayed before you.
Well those clever Regular Expressions supply a tasty Box of Chocolates as well.
So You Want to Learn Regular Expressions? Part 4: More Wildcards
Submitted by Steve on November 9, 2008 - 6:56pm.The full list of Regular Expression Articles I've done:
- What and How? - Wherein we look at What a Regular Expression actually is, and How they basically work.
- Wild Cards - A starting look at the use of wildcards. Ways to find lots of stuff.
- Positioning - Finding stuff is good. Being able to specify where stuff may be found is better.
- More Wild Cards - More ways to find lots of stuff.
- Just Like a Box of Chocolates - The Ultimate Analogy. Single choices from between Square Brackets.
- Choices, Choices, Choices.... - Exposing bigger choices: Err... Or.
- Filtering IP Addresses - Wherein I bore the reader to tears explaining how to RegEx for IP Addresses.
In this instalment of this series on Regular Expressions, I'll expose a wee lie from part 2, and show how wildcards can be less wild. More controlled. And hence more useful.
A LIE????
Urm. Yes. Not to put too fine a point on it. A school/teaching progression type of lie. You see a ".*" construct isn't actually a wildcard. The asterix is the wild card. All on its very own. Similarly the plus "+" in ".+".
So You Want to Learn Regular Expressions? Part 3: Positioning
Submitted by Steve on November 9, 2008 - 6:51pm.The full list of Regular Expression Articles I've done:
- What and How? - Wherein we look at What a Regular Expression actually is, and How they basically work.
- Wild Cards - A starting look at the use of wildcards. Ways to find lots of stuff.
- Positioning - Finding stuff is good. Being able to specify where stuff may be found is better.
- More Wild Cards - More ways to find lots of stuff.
- Just Like a Box of Chocolates - The Ultimate Analogy. Single choices from between Square Brackets.
- Choices, Choices, Choices.... - Exposing bigger choices: Err... Or.
- Filtering IP Addresses - Wherein I bore the reader to tears explaining how to RegEx for IP Addresses.
If you've been tracking the public discussion on Robbin Steif's blog regarding this series, you'll no doubt be aware that she was prompting me (in a really unsubtle fashion ;-) ) to explain the use of the "beginning" and "end" characters. ^ and $ respectively.
So that's what this episode in the series will be focusing on.
So You Want to Learn Regular Expressions? Part 2: Wild Cards
Submitted by Steve on November 9, 2008 - 6:49pm.The full list of Regular Expression Articles I've done:
- What and How? - Wherein we look at What a Regular Expression actually is, and How they basically work.
- Wild Cards - A starting look at the use of wildcards. Ways to find lots of stuff.
- Positioning - Finding stuff is good. Being able to specify where stuff may be found is better.
- More Wild Cards - More ways to find lots of stuff.
- Just Like a Box of Chocolates - The Ultimate Analogy. Single choices from between Square Brackets.
- Choices, Choices, Choices.... - Exposing bigger choices: Err... Or.
- Filtering IP Addresses - Wherein I bore the reader to tears explaining how to RegEx for IP Addresses.
In the previous article (So You Want to Learn Regular Expressions?) I hopefully managed to explain the underlying concept of using regular expressions via the Analogy of a jail.
In this article we'll start to explore the use of wild cards - what they are when to use them, and more importantly, when NOT to.
When NOT to use Wild Cards
Yes. You see, a regular expression will usually have two implied wild cards.
So You Want to Learn Regular Expressions?
Submitted by Steve on November 9, 2008 - 6:10pm.The full list of Regular Expression Articles I've done:
- What and How? - Wherein we look at What a Regular Expression actually is, and How they basically work.
- Wild Cards - A starting look at the use of wildcards. Ways to find lots of stuff.
- Positioning - Finding stuff is good. Being able to specify where stuff may be found is better.
- More Wild Cards - More ways to find lots of stuff.
- Just Like a Box of Chocolates - The Ultimate Analogy. Single choices from between Square Brackets.
- Choices, Choices, Choices.... - Exposing bigger choices: Err... Or.
- Filtering IP Addresses - Wherein I bore the reader to tears explaining how to RegEx for IP Addresses.
Perhaps you've been forcibly inducted into the Joy Of Regular Expressions through the use of tools like Google Analytics. Unfortunately while perfectly correct, the Google Analytics help for Regular Expressions is brief and does not explain the why of when to use X vs Y.
Hopefully the following article will get you through the why. I’m going to assume you’ve had at least some exposure to using Regular Expressions already.
So You Want to Learn Regular Expressions?
Submitted by Steve on October 10, 2006 - 10:35pm.Herein you will find a series of articles aimed at helping the non technical person understand what Regular Expressions are, how and when to use them and hopefully help to get into the mindset of using the darn things!
The main focus has been on helping non technical people, mainly business and marketing, use Regular Expressions in Web Analytics tools like Google Analytics and others.


