CODE CREW SUGGESTED READING #2: REGULAR EXPRESSIONS
A regular expression is a pattern that allows you to match (specify and recognize) strings of text like a character, word or pattern of characters.
For example, if I want to search for duplicate telephone numbers in my application I may write a regular expression that matches any non-number character (dashes, parentheses, periods, spaces, etc.) and then write code to strip them from each telephone number so I can compare each phone number as 7 digit strings.Â
So if my program asks a user for a home phone number and user1 inserts his phone number as "(212) 555-1234" and user2 inserts his phone number as "718-555-1234", I can use a regular expression to help me write some code to change these inputs to "2125551234" and "7185551234" respectively.Â
Say, for example, user3 comes along (who happens to be user1's wife) and inserts her number as "212.555.1234" I can write a regular expression that matches the periods in her number then write code to remove them to convert her number to "2125551234". My program will now know that user1 and user3 have the same exact number.
The string "(212) 555-1234" is not equal to the string "212.555.1234" because of the parentheses, dashes, periods and spaces
However, if I write a regular expression to match the parentheses, dashes, periods and spaces and write code to remove them, the two numbers become "2125551234"
and "2125551234" is equal to "2125551234"
To get a better idea of what regular expressions are, Nettus has some pretty good articles and a video tutorial on the subject. They're in JavaScript but the same idea applies to most programming languages; you would just have to check the documentation of the specific language you're using.
Links to the tutorials are below:
Regular Expressions for Dummies (Screencast)
You Don't Know Anything About Regular Expressions (Text)
8 Regular Expressions You Should Know (Text, and pretty useful if you're building an app)
  * Rubular is actually a pretty good site to test your regular expressions written in Ruby (Python and JavaScript people feel free to chime in the comments if you know of a similar site for those two languages).Â