Mastering Regular Expressions

By Jeffrey E.F. Friedl

The first edition of Mastering Regular Expressions by Jeffrey E.F. Friedl tries to explain the way regular expressions work, and how you can work with them. In this edition he focuses on Perl; the second edition is said to pay more attention to Python. Not a very useful book, I’m afraid.

I consider this book rather a — what’s the English for ‘miskoop’?. Well, I shouldn’t have bought it. Not just because the moment Amazon delivered it to my doorstep, the second edition that offers more Python converage, but because the text itself is flawed.

Let me expand on that. I needed this book because I wanted to write several complex applications for which regular expressions seemed best suited. Since I’m pretty much a self-taught programmer, I haven’t had the formal training in formal languages and compiler design that would have made using regular expressions a snip.

In order to reach that goal I needed a text that would explain how regexpses work, how to use them and what the pitfalls are. Succinctly, and with a minimum of fuss.

Friedl, however, suffers from the common O’Reilly disease (and I must admit that I cheerfully copied that in my book on GUI programming with Python): the authors tries to be witty. Funny. Verbose. Countless cute metaphors about cars and engines make it difficult to find what you need, or even to read at any speed.

Part of that lack of progress is because the book doesn’t display any celerity: around page 73 we’re still dealing with common metacharacters. And after the chapter on backtracking, the differences between the various flavours of regular expressions found in Emacs, Perl, Python and so on are treated, but not in any real detail.

And chapter 7 deals just with Perl. Well, perhaps I just had the wrong expectations, or perhaps I already knew too much about a subject I thought I was pretty ignorant in…

A much better choice would have been to buy the Dragon book, that is, Compilers, Principles, Techniques and Tools, by Alfred V. Aho, Ravi Sethi, Jeffrey D. Ullman (Contributor). That explains what regular expressions are in fine detail.