I just heard from my editor at O’Reilly that Regular Expressions Cookbook, written by Steven Levithan and me, is now shipping. When I write this, Amazon.com still lists as a pre-order with a June 4 release date. I’m sure they’ll fulfill all pre-orders by that date, so don’t wait with buying your own copy! If you use one of the links below to order, Amazon will pay me an affiliate commission, which will pretty much double the slice I get from what you pay for the book. I’ve listed the names of the countries to which Amazon offers free shipping. The list price of the book is US$ 44.99. The various Amazon sites offer different discounts, up to 34%, with free shipping to various countries:
The book covers the regular the regular expression flavors .NET, Java, JavaScript, Perl, PCRE, Python, and Ruby, and the programming languages C#, Java, JavaScript, Perl, PHP, Python, Ruby, and VB.NET. After a quick introduction, the book starts with a detailed regular expression tutorial which equally covers all 7 regex flavors. That chapter is followed by a detailed guide how to implement regular expressions in your source code, again covering the 8 programming languages equally. These chapters too are presented in cookbook format. You can easily pick out the task you want to accomplish when creating a regular expression of your own, and when you want to do something with a regex in your source code. While there’s some repetition, particularly in the programming guide, because of our goal of equal coverage, the benefit is that you can easily skip the parts on programming languages you’re not interested in, in true cookbook style.
The remaining chapters, over half of the book, present real-world problems, and how to solve them with regular expressions. These problems range from very simple problems and everyday regex tasks, to some complex problems that stretch the limits of what you can do with regular expressions, but show how a regex-based solution is often much quicker than doing the same in procedural code, particularly if you only need to do the job once. All the real-world problems also have solutions for all regex flavors. A few solutions add procedural code to make up for missing regex features, such as JavaScript lacking lookbehind. The book does not cover regex flavors with limited features such as the venerable POSIX standard. We didn’t want to put those flavors on the cover and then disappoint readers by saying “can’t be done with this limited flavor” for half of the recipes in the book.
If you use regular expressions with the latest versions of PowerGREP, EditPad Pro or AceText, you can use pretty much any of the regular expressions presented in the book. These products use a custom regex flavor that is a fusion of the features found in the flavors covered in Regular Expression Cookbook. RegexBuddy 3 emulates all the flavors in the book. Older versions of these products are based on PCRE 4, without Unicode support.
Regular Expression Cookbook targets people with regular expression skills ranging from zero to upper intermediate, who want to learn about regular expressions for the first time, or sharpen their skills to become experts. Except for the chapter on programming languages, most of the recipes in the book don’t require programming skills to implement the solutions in EditPad Pro, PowerGREP, or any other text editor or search tool that uses one of the book’s regular expression flavors. The programming chapter assumes you’re familiar with all the basic features and syntax of your programming language, but it doesn’t assume you’ve ever used regular expressions in your source code.
While the jury has only just received their copies of the book, I dare say that Regular Expression Cookbook is the most practical book on regular expressions to date, filled with lots of detailed information about flavor-specific and language-specific features or issues glossed over by many other books and online articles.