24 May 2011

Mastering Regular Expressions (O'Reilly)

Many programmers use regular expressions frequently, but most of us can go for months, if not more, between the occasions when we really need to understand what the heck the regex implementation is doing.

For those times when you actually need to know, Mastering Regular Expressions, by Jeffrey Friedl (ebook version available on O'Reilly) is the book you want to have read. It does discuss various regex features, but you can usually find the same info in the API docs for the language bindings you're using; the real meat of this book is its clear discussion of regex engine implementations.

When you want to answer such questions as "Why is the regex engine matching the string P, and not the different-but-equally-valid match Q?" or "How can I make this regex code faster?", then it really helps to understand what's going on under the hood. NFAs, DFAs, state machines, and all that good stuff are covered here, but with many more practical notes than appear in your college compilers textbook.

Recommended... if you're into this sort of thing.

No comments:

Post a Comment