Review: Regular Expressions Cookbook, 2nd Edition

Published Oct 19, 2012 (12 years ago)
Danger icon
The last modifications of this post were around 12 years ago, some information may be outdated!

Regular Expressions Cover

I'll never forget the day I came across regular expressions. I was a year out of college and at my first "big" job at a major University and I ran into a challenge where I needed to detect the status of destination of packages arriving on campus based on a special reference code that was attached to the packages. While there were a large amount of options that made hard coding the processing undesirable, the format of the reference code was easy to discern. From here I discovered that regular expressions allowed me to get my location, floor, and sometimes room in two or three simple lines of code. Since then I've always tried to keep somewhat up to par on my regular expression proficiency. That is why I was really excited to come across Regular Expressions Cookbook, 2nd Edition by Jan Goyvaerts and Steven Levithan that provides everything I need to work with Regular Expressions.

The book opens up with a general overview of what regular expressions are and the various "flavors" of regex parsers that exist. Flavors and primarily geared toward what programming language you are using (.Net, Ruby, Javascript, etc.). Interestingly enough, each flavor has a unique features built into them, so knowing which flavor you are working with does matter at times.

After this the book progresses from simple regular expression "recipes" (select just numbers, selecting words) to intermediate recipes (selecting phone number or date formats) to advanced recipes involving URLs, HTML, and XML. Each recipe provides special instructions based on the flavor you are using. A paragraph of discussion follows the recipe outlining justification for a certain formula, or interesting fringe cases you may encounter. Finally, if any similar recipes exist, a reference to them is provided.

This is the structure for the over 100 recipes in the book. Each recipe is extremely insightful, and just like any cook, after reading the introduction to the format and notation of regular expressions, you'll be able to "cook up" anything you need by simply following the directions. This book is perfect for every grade of programmer. Novices will benefit from the well written overview and be able to comprehend the fundamentals of regular expressions and their processing. Intermediate developers will be able to look at existing recipes as a base in order to modify the recipe for their custom needs. Expert developers will be happy to have a handy reference guide for any regular expression they need.

Regular Expressions Cookbook, 2nd Edition is an essential book to any programmer. It's concise, yet insightful overview of regular expression parsing will help novices learn the key concepts quickly. The well documented recipes provide the perfect reference for intermediate and expert programmers.

You can get this book through O’Reilly Books at