BOOK Mastering Regular Expressions

Mastering Regular Expressions, by Author: Jeffrey E. F. Friedl, is the most widely-cited reference work on regular expressions.


Jeffrey E. F. Friedl
website (first edition)
website (second edition)
website (third edition)
website (third edition)


This book explains regular expressions in general, and then covers a number of different tools explaining specialized variations. The book focuses more on Perl, but Tcl is one of the tools covered in its own special section. And more...

The second edition praises Tcl's regular expression engine: Henry's Tcl regex engine is an important step forward.

Also, in Chapter 6: Crafting an Efficient Expression, Friedl says: Most of what this chapter talks about simply does not apply to Tcl. And, as the sidebar explains, Henry Spencer's Tcl regex is a hybrid DFA/NFA engine and it doesn't need most of the optimizations described in the chapter.

In Chapter 4 of the third edition, The Mechansics of Expression Processing, Friedl says: Tcl’s regex engine is a true hybrid, custom built by Henry Spencer (whom you may remember having played an important part in the early develop- ment and popularization of regular expressions, page 88). The Tcl engine some- times appears to be an NFA — it has lookaround, capturing parentheses, back- r efer ences, and lazy quantifiers. Yet, it has true POSIX longest-leftmost match (page 177), and doesn’t suf fer fr om some of the NFA pr oblems that we’ll see in Chapter 6. It really seems quite wonderful.