Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Mastering Regular Expressions

by splinky (Hermit)
on Jul 09, 2000 at 00:27 UTC ( #21667=bookreview: print w/ replies, xml ) Need Help??

Order Mastering Regular Expressions

Item Description:

Review Synopsis:

Mastering Regular Expressions by Jeffrey Friedl
ISBN 1-56592-257-3
Copyright 1997 O'Reilly & Associates, Inc.

Capsule Review

Excellent book. 5 stars out of 5.

Who should be interested in this book?

  • Anyone who works on a machine with Unix variant OS
  • Anyone who finds perlre too dry or daunting
  • Anyone who has always wondered what a regular expression engine was like under the hood but never bothered to try to read the code

Full Review

Mastering Regular Expressions by Jeffrey Friedl is, without a doubt, THE book about regular expressions. To my knowledge, there is no other book devoted specifically to the subject, nor need there be now that Jeff's taken care of the matter.

The next time you're in the book store wondering whether to buy it, pick it up and turn to Tables 6-1 and 6-2, titled, "A Superficial Survey of a Few Common Programs' Flavor" and "A Comical Look at a Few Greps", respectively. If, after perusing these nuggets, you still don't think you need the book, then just walk away. I can think of no more persuasive argument. That page is bookmarked with a Post-It in my book, but it's completely unnecessary because the book naturally falls open to that spot. I use it that much.

The book opens with a couple of chapters that introduce the reader to regular expressions. Good examples and clear prose bring the subject down to a level where any competent programmer can understand it. But be sure to read the typographical conventions in the Preface. Otherwise, you may wonder what language the examples are written in.

The two most useful sections of the book for most Perl programmers will be Chapter 5, "Crafting a Regular Expression" and, of course, Chapter 7, "Perl Regular Expressions". As you read Chapter 5, you'll probably be surprised by how much you DON'T know about creating a functional and efficient regular expression. And Chapter 7 is, without a doubt, the most comprehensive discussion of Perl's particular regular expression features that you'll find anywhere.

Chapter 4, "The Mechanics of Expression Parsing", will separate the casual, 40-hour a week programmers from the REAL programmers. In this chapter, you'll learn exactly how regular expression engines work. By the end, you'll know your DFAs from your NFAs, and you'll be able to talk bump-along and backtracking with the best of them. And when someone mentions POSIX regular expressions, the words "Longest leftmost" will be out of your mouth before you know what happened.

The rest of the book is mostly tool-specific information. TCL, AWK, and GNU Emacs are covered in depth, in addition to Perl.

So, is there anything wrong with this book? Well, yes, I suppose there is. First, if anything, it covers its subject TOO thoroughly. I mean, let's face it, most people aren't going to be terribly interested in Chapter 4. I liked it, but I'm kinda weird that way. The majority of people could make do with chapters 1 and 2, and maybe 7 if they do Perl regularly.

The second problem is that chapter 7 is a little dated at this point. I would hate to be an author trying to keep up with Ilya Zakharevich's enhancements to the Perl regular expression engine. Fortunately, most of Ilya's major enhancements are very advanced features which most people will never understand well enough to use, so chapter 7 will continue to serve most people just fine. Still, I'd love to see Jeff come out with Revision 2 at some point.

But until and unless that happens, my well-worn copy of MRE will remain close at hand for the foreseeable future. Why? Because Perl's regex features may continue to grow and expand, but Table 6-1 will be relevant as long as Unix variants exist in the world.

*Woof*

Comment on Mastering Regular Expressions
Download Code
RE: Mastering Regular Expressions
by mirod (Canon) on Sep 06, 2000 at 20:49 UTC

    As numerous bug reports on p5p show, Jeff has recentlly started working on Revision 2. Judging by the type of bug and the heated debates with Ilya over how deep he should go into his explanantions it looks like it should be at least as detailed as the first edition.

RE: Mastering Regular Expressions
by frankus (Priest) on Oct 12, 2000 at 18:55 UTC
    I devoured the Mastering Regular Expressions, it is so easy to read, it makes Regular Expressions easy on the brain. It helped me a great deal with it's approach to what can be a really imposing topic.

    --
    
    Brother Frankus.
      Master Regular Expression == Master Perl. This book should be part of the regular diet of Perl coders. My copy of MRE falls naturally open to Chapter 7 which deals exclusively with Perl. Highly recommended.
Re: Mastering Regular Expressions
by Hanamaki (Chaplain) on Aug 25, 2001 at 19:25 UTC
    I own quit a lot of books on Perl. But when I look on my desk or bookshelfs the only ones you don't want to touch without rubber gloves are Mastering Regular Expressions and Camel 2. Look at this books and you will know they had a hard time and traveled a lot.
    If you are not one of the "Wash your hands before you thouch the book" & "Allways treat books nicely" pedants you will know which are your most valuable books just by looking at them.

    In my opinion this book is one of the most exciting, helpfull and entertaining computer books I have ever bought. And it is not difficult, but easy to understand. Just 2 weeks ago I gave it to a linguist colleage (without programming experience) of mine and even she got excited on Regular Expressions while just using different dialects of grep.
    Its not just a Perl book, but The Survival Guide for people with too much Data.

    Hanamaki
Re: Mastering Regular Expressions
by davido (Archbishop) on Aug 26, 2003 at 03:46 UTC
    Mastering Regular Expressions, by Jeffrey Friedl is so good, I just don't see how anyone can do without it if they're using regular expressions at all.

    If you've ever been tricked by greedy quantifiers, lazy regexp engines, confusing lookaheads, backreferences, POSIX character classes, inline eval, recompilation, sluggish alternation, and so on, you need this book. If you don't recognize some of those terms, you really need the book. I know that the Perldocs are touted as being the definitive source on Perl, but in the case of Regular Expressions, the Owls book has got to be the standard work.

    Every time I see regular expression related questions posted to Perlmonks, Usenet, or anywhere else, I think, "Why didn't this person just read Mastering Regular Expressions?" It's the book that turns run of the mill Regular Expression authors into Masters of the Craft.

    When you read it, be prepared to start seeing everything in life in terms of regular expressions (except for irregular things, of course). And be prepared to start counting to ten a lot before posting replies when you see questions on Perlmonks.org by those who obviously haven't been to the fountain yet. You can spot them immediately. It's ok, your work is easier than theirs because you took a few days and read this book. Go easy on them.

    If there ever were a mountain with a guru sitting atop in a secluded hut, Friedl would be that guru, and the otherwise arduous journey to the mountain top would be facilitated by the Owls book like an air-conditioned tram car. The journey back down, of course, would be in the slipery slide of an efficient regular expression.

    Dave

    "If I had my life to do over again, I'd be a plumber." -- Albert Einstein

Re: Mastering Regular Expressions
by xenchu (Friar) on Jan 18, 2004 at 16:57 UTC

    Mastering Regular Expressions mod. 2 is out and I am reading it now. It is clearing up some of my many dim spots about regex. I strongly recommend version 2 even if you have version 1. It has a lot of new information. And if you don't have version 1, well...

    xenchu


    The Needs of the World and my Talents run parallel to infinity.
Re: Mastering Regular Expressions
by martin (Pilgrim) on Feb 04, 2006 at 17:49 UTC
    One nice feature of the book (both editions) should also be mentioned here: Its singularly ingenious typesetting.

    Using a sophisticated but quite intuitive notation the author maintains always a clear picture of what portion of an expression or position in a string he is talking about, where exactly literal space characters occur, what matches what, which parentheses belong together, and so on.

    This is a significant factor in keeping the discussion of such complex matters concise and straightforward. I have yet to see other technical writing reaching the same level of clarity through just the right kind of typesetting.

Re: Mastering Regular Expressions
by diffredential (Beadle) on Dec 12, 2008 at 23:47 UTC
    Hi! I have both the first edition (1997) and the second edition (2002) and I'm wondering if it's worthy buying the 3rd edition or MRE, anyone can recommend me? thanks!
Re: Mastering Regular Expressions
by sv87 (Acolyte) on Nov 27, 2009 at 19:43 UTC

    For me personally, I like to have books that treat the subject matter very thoroughly, I'd rather have a lot of information, than too little. Of course, there's never a be-all end-all book of Perl programming. I highly recommend this book, it's really worth the reading if you're looking for some better understanding of regular expressions.

    Reach out and grep someone.

Back to Reviews

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: bookreview [id://21667]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (11)
As of 2014-10-20 12:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (76 votes), past polls