Regular Expressions Cookbook Has Been Published
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.
Updated 29 August 2012: Amazon links now point to the second edition, which has all content of the first edition, plus more:
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.
Congratulations on seeing your name in print Jan! Must be very satisfying after all the effort, especially in light of your belief it’s the most practical regex book to date – fantastic!
Comment by boardtc — Wednesday, 27 May 2009 @ 17:50
I thought I’d be looking forward to the book, but without Delphi code……
Comment by Dave — Wednesday, 27 May 2009 @ 19:57
The book has one chapter about programming with regular expressions. There are no Delphi code samples in that chapter, because Delphi for Win32 doesn’t have a built-in regex engine, and Delphi for .NET and Delphi Prism use the .NET engine for which we have full code samples in both C# and VB.NET. Adding a 3rd .NET language would add too much redundancy.
All the other chapters focus on regular expressions, rather than on programming languages. These chapters fully cover the .NET regex flavor (used by Delphi for .NET and Delphi Prism), and the PCRE regex flavor (used by most regex components for Delphi for Win32).
If you’re a Delphi developer who wants to learn (more) about regular expressions, you will definitely benefit greatly from this book. For Delphi for Win32 code samples, you’ll need to refer to the documentation with the Delphi component or PCRE wrapper that you are using.
Comment by Jan Goyvaerts — Thursday, 28 May 2009 @ 14:02
I have received a mail from amazon.fr saying that delivery is delayed.
Do you have info on that ? I maintain my order, of course !
Thanks
Alexandre
Comment by Alex — Wednesday, 10 June 2009 @ 0:41
Amazon.com has already shipped all pre-orders and has the book in stock. I have no insight in Amazon’s distribution system. I suppose it takes a bit longer for the book to reach Europe.
Comment by Jan Goyvaerts — Wednesday, 10 June 2009 @ 7:54
[…] who already consider themselves regex experts. For those who’d like to know more, Jan has a good summary on his blog, and here is O’Reilly’s press release for the […]
Pingback by Regular Expressions Cookbook is Out — Monday, 15 June 2009 @ 4:45
The book sounds really great. I am just starting to use regular expressions a lot more in my PHP. Unfortunately, I don’t buy books from publishers that don’t offer sample chapters. O’Reilly used to be good about that, but then they stopped offering them.
Comment by David Troidl — Wednesday, 24 June 2009 @ 21:44
Here’s an article which should be helpful to others:
Analyzing Unicode Text with Regular Expressions
http://icu-project.org/docs/papers/iuc26_regexp.pdf
Using Regular Expressions with Unicode texts can be a nightmare, largely as (too) much public documentation is geared towards using them just with ANSI characters.
This 18 page article from 2004 rectifies a lot of that.
Comment by David Haslam — Monday, 26 October 2009 @ 16:21
In chapter 2, Regular Expressions Cookbook discusses all the Unicode-related features of the regular expression flavors that it covers and points out the sometimes rather subtle inconsistencies between those flavors.
Comment by Jan Goyvaerts — Tuesday, 27 October 2009 @ 14:38