Slashdot Mirror


Mastering Regular Expressions

Simon P. Chappell writes "Classics are funny things, especially in the world of books. There are books that people say "should' be classics (I'll refrain from mentioning names to protect the pretentious) and then there are books that people are too busy actually using to get around to listing as classics. Mastering Regular Expressions, now in it's third edition, is in the second group. It's one of those books that you see on desks in computer departments the world over. This is a real "doers" book." Read the rest of Simon's review. Mastering Regular Expressions author Jeffrey E.F. Friedl pages 515 (31 page index) publisher O'Reilly rating 11 out of 10 reviewer Simon P. Chappell ISBN 0596528124 summary A classic of modern computer literature.

This is a book for programmers; managers, project managers and architects need not apply. If you talk about code instead of writing it and have teams of programmers report to you, then consider buying this book and giving it to them. If you're a technical lead or lead programmer, then shame on you if an earlier edition of this book isn't already on your shelves! The majority of examples are written using Perl, but if you can read basic Perl (Pidgin Perl, perhaps?) then you'll be fine with the examples. Programmers in PHP, Java, .NET and Ruby also have dedicated sections of the book, so it's very inclusive and almost platform agnostic.

The book has ten chapters divided into two parts. Chapters one through six are what Mr. Friedl calls the "story" of regular expressions. Chapters seven through ten are an examination of the specific regular expression capabilities of Perl, Java, .NET and PHP.

Chapter one is an introduction to regular expressions. At only 33 pages, you might think that it would be shallow, but rather, it is knowledge dense. The examples in the first chapter use egrep extensively. This makes a lot of sense as it's an advanced tool, easy to use and freely available for most modern operating systems.

Chapter two builds on this introduction with extended introductory examples. These are written in Perl (again, simple and easy to follow), but there is no doubt that the regular expressions are the stars of the show around here. The examples are small Perl programs, but their benefit is that Mr. Friedl talks the reader through the process of creating each of them. This is more useful than just presenting example programs, because with just pure examples, you are out of luck if your specific problem is not covered. With this approach, you're coached towards thinking in regular expressions and are more equipped to address your personal regular expression needs.

Chapter three provides an overview of regular expression features and flavors. It starts with a historical view of the development of regular expressions, including a few asides about the influence that the earlier versions of the book have had on that development. After that, the chapter uses a search and replace example to demonstrate some of the differences between flavors of regular expression capabilities provided by different programming languages. Strings, Unicode and metacharacters round out this overview.

Strap yourself in for chapter four; it's time to talk about the computer science that makes all of that matching work. If you didn't know the difference between an NFA and a DFA regular expression engine before you start this chapter, you most certainly will by the end of it. At first sight, it might seem that this is chapter for the pure propeller heads amongst us. While there is much theory here, it's all presented in the light of how your regular expression engine is trying to do what you asked. By understanding the approaches to regular expression processing, we can learn to help ourselves. We help ourselves when we write regular expressions that run faster and use less memory. We write better regular expressions when we understand the consequences of what we write. For example, the oft written ".*" (dot star) seems like a great way to ignore a bunch of stuff in the middle of an expression, but such simplistic use is just waiting to bite you. This chapter explains why and how to deal with the situations where you'd be tempted to use simplistic expressions and how just a little extra thought can bring you the behavior you want.

Chapter five is a practical counterpoint to the previous theory chapter. Here, Mr. Friedl discusses practical regular expression techniques. There are a number of short examples, before he works through medium sized HTML processing examples and finished up with a look at processing Comma Separated Value (CSV) data.

Chapter six is efficiency. Your regular expression can be as correct as you like, but if it takes what seems like eternity to run, then it's of little use. This chapter mostly addresses NFA based engines, because they have the greatest variability based on how the regular expression is written.

Chapters seven through ten cover the specifics of using regular expressions in Perl, Java, .NET and PHP. They're well written and cover everything you need to apply the content of the first six chapters to your programming language of choice.

Everything about this book is great. This is the kind of book that O'Reilly built its reputation with. A master of the subject matter, writing in a clear, easily understood manner, leaving the reader educated and able to operate comfortably with the subject matter. I may not be a regular expression guru, but I feel that I have a much better grasp of the fundamentals that I would need if I did want to be such a guru.

Mr. Friedl is to be commended for his clear explanations of what is, in all reality, much more complex computer science than many of us are used to dealing with. The fact that his explanations are highly readable and enjoyable is a significant bonus.

There is a website for the book, regex.info and a blog at regex.info/blog, where Mr. Friedl has some wonderful photographs of Japanese gardens with their autumn colors. (Nothing to do with regular expressions, but they appealed to my inner photographer.)

Lastly, while the book is not intended to be an encyclopedia of regular expressions, all of the examples are very relevant to programmers needs and this book can easily serve that reference role.

At the risk of sounding like some kind of O'Reilly shill or a relative of Mr. Friedl, I must report that I don't think that I found a single thing I didn't like about this book.

This is a classic of the first order. Nail it to your desk unless you want to be constantly retrieving it from your co-workers. If I might be permitted a Spinal Tap reference, this one goes to eleven. If you ever use regular expressions, are thinking of using regular expressions or are in the same room as a regular expression, then you need this book.

You can purchase Mastering Regular Expressions from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.

46 of 208 comments (clear)

  1. Maybe it's just me... by grub · · Score: 2, Funny


    ...but it seems funny that someone signing himself as Simon P. Chappell would worry about "protect[ing] the pretentious".

    --
    Trolling is a art,
    1. Re:Maybe it's just me... by Sideshow+Coward · · Score: 5, Funny
      protect[ing] the pretentious
      Don't you mean "protect(ing)? the pretentious"?
    2. Re:Maybe it's just me... by leonardluen · · Score: 4, Funny

      i see you have not yet mastered reqular expressions

    3. Re:Maybe it's just me... by Paul+Rose · · Score: 3, Funny

      I use my middle initial all the time for that reason
      What? Anonymous J. Coward

    4. Re:Maybe it's just me... by Anonymous+P.+Coward · · Score: 2, Funny

      No, "P" for Pleanty-of-other-people-named-Anonymous-Coward

    5. Re:Maybe it's just me... by wavq · · Score: 2, Insightful

      $_ =~ s/q/g/;

  2. Knock Knock by neonprimetime · · Score: 5, Funny

    What did one regex say to the other?

    .+

    1. Re:Knock Knock by A+beautiful+mind · · Score: 4, Funny

      You're not a geek if you don't find .* of it funny.

      --
      It takes a man to suffer ignorance and smile
      Be yourself no matter what they say
    2. Re:Knock Knock by merc · · Score: 4, Funny

      greedy bastards! .*?

      --
      It's true no man is an island, but if you take a bunch of dead guys and tie 'em together, they make a good raft.
  3. I bought/read this a couple months ago. by Jester998 · · Score: 5, Interesting

    I bought this (along with a few other O'Reilly titles) a couple months back, and I highly recommend Mastering Regular Expressions. Even though it's a dry technical topic, the presentation is awesome.

    I read through the whole thing as if it were a novel, and picked up more than a few new things about regexes.

    Very handy book, both to read through to really learn how regexes work, and as a day-to-day reference. The score of 11/10 given by the reviewer is bang on.

  4. My Expressions by Anonymous Coward · · Score: 3, Funny

    are always sad

  5. We need to protect all expressions by 140Mandak262Jamuna · · Score: 4, Funny

    The author and the reviewer are blatantly biased in favour of the regular expressions, ignoring the plight of the millions of downtrodden irregular expressions who are not able to get a platform to voice their grievances. All because they are viewed as somehow deviant or deficient. It is time for the irregular expressions to come out of the closet and assume their role as legitimate members of the syntax.

    --
    sed -e 's/Chuck Norris/Rajnikant/g' joke > fact
    1. Re:We need to protect all expressions by Mattintosh · · Score: 5, Funny

      I would suggest using some laxatives

      Would that be RegExLax?

  6. Re:Agreed! by Anonymous Coward · · Score: 2, Interesting

    Guess what - in Silicon Valley, a bunch of sometimes arrogant, more often brilliant, unrepentant commercialists made a system for the Macintosh called MPW. I used their proprietary system for years. I never wanted to deal with four uses of * and / and . and all the others. With a few greek characters, the expressions for Position before A, and Selection between A nd B and a bunch of others worked really, really well.

    Now that NeXT acquired Apple, the web is indispensible, and the BSD that drives the Mac is settled, I now use regular expressions as in this book. They are not bad, but not the only way, either. Simply put, they won. There will never be another set of regular expressions for 1000 years now, but dont forget, there is More than One Way to Do Things.

  7. Re:Third Edition? Already? by MrBoombasticfantasti · · Score: 2, Funny

    From the review:

    Mastering Regular Expressions, now in it's third edition, [...]

    I'm keeping my second edition though. My book fetish is already expensive enough without buying every edition and reprint... ;-)

    --
    !ERR: Signature not found.
  8. Personally... by rainman_bc · · Score: 5, Informative

    I just like to go to http://www.regular-expressions.info/ myself - I seem to find all the stuff I forget from time to time there...

    --
    09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0
    1. Re:Personally... by owlstead · · Score: 2, Insightful

      Note that I immediately found erros on the Java section of this site. E.g., according to the site, the default Java regexp support does not include searching for case insensitive strings, which it does. Beware.

  9. Re:For Programmers? NOT! by gurps_npc · · Score: 4, Insightful

    Their are and continue to be a LOT of people that start off dablling, get a job and become full time programmers without EVER getting a formal education in computer science. You can easily get a 60k job doing that. While someone with a good formal education can get paid a lot more, these people are still programmers.

    --
    excitingthingstodo.blogspot.com
  10. Maybe it's just me but isn't 515 pages too much? by Anonymous Coward · · Score: 2, Insightful
    Does anyone remember "Moby Dick" (hint: "Call me Ishmael ...")? It weighed more than Roseanne Barr/Arnold/Thomas because publishers charged more money for heavier books and thus encouraged the writers to write big books.

    Now, we have a regular-expression primer that has 515 pages. Is the publisher earning more money by producing a bigger book?

    The only information that most people need is contained on a small web page. Armed with the information on that web page, the beginner can learn best by doing: writing various regular expressions in short Perl programs and determining whether they do what you want them to do.

  11. an anecdote caused by this good book by Sebastopol · · Score: 3, Interesting

    When I read the 2nd edit of this book I was floored by how much richness I was missing in the regex language (well, in Perl regex, that is).

    Like I kid at christmas, I immediately went nuts on my next project with \G and the lookaround operator(s).

    Sadly, when a big bundle of code I wrote was delivered to a team in a city on another very large eastern continent, no one could understand what I had written, so they deleted my nifty \G loops and replaced it all with a crappy first-year-college-grad-non-indented parsing state machine using gotos. The complaint was not that I went nuts with regex, but that I was using NONSTANDARD perl version which supported them (instead of their ancient version!), and that it was my duty to deliver a tool using standard versions. I was most angry at the fact that they just replaced the code with a buggy state machine, and then asked me to debug another problem caused by their mess because it was my tool originally. Ugh!

    Anyway, my point is: (perl) regex are a far richer tool than meets the eye, but beware The Boneheads: the people who refuse to learn something new that could make their life easier and cling to the old way. Gawd forbid someone learn something new on the job.

    Sigh. I was hoping at least ONE programmer over there would have shared my enthusiasm for \G. /endrant

    --
    https://www.accountkiller.com/removal-requested
    1. Re:an anecdote caused by this good book by Sebastopol · · Score: 3, Informative


      The regex extentions have been mainstream since perl5.8.

      The other co. is using perl5.004, which doesn't even support >2GB files.

      Trolls are the worst when they make uninformed assertions, you must work for the company that got my code.

      --
      https://www.accountkiller.com/removal-requested
  12. I'll not refrain by cptgrudge · · Score: 2, Funny

    There are books that people say "should' be classics (I'll refrain from mentioning names to protect the pretentious)

    I'm not going to refrain.

    The Three Musketeers, Alexandre Dumas
    Pride and Prejudice, Jane Austen
    David Copperfield, Charles Dickens

    Look at me, I'm being pretentious!

    --
    Qualitas edurus commercium, nullus penitus net rimor, nullus deus beneficium
  13. Re:New for 3rd Edition by Skiron · · Score: 2, Funny

    Yes, they missed a . on page 102, paragraph 14.

  14. Two problems by MarkByers · · Score: 2, Funny

    Some people, when confronted with a problem, think I know, I'll use regular expressions. Now they have two problems.

    --
    I'll probably be modded down for this...
  15. Regular Expressions are of the Devil by trigeek · · Score: 3, Funny

    To quote: "Sometimes a hacker has a problem, and he thinks to himself 'I know, I'll solve it with a regular expression!'. Now he has two problems." -- Jamie Zawinski

    --
    Sometimes I doubt your committment to SparkleMotion!
  16. I once wrote a complete... by pyrrho · · Score: 2, Funny

    .... wordprocessor and email program with a regular expression!

    PS: not really but wouldn't that be feckin' awesome! it was emacs... if I really had done it I mean.

    --

    -pyrrho

  17. Re:For Programmers? NOT! by Amouth · · Score: 2, Interesting

    that is me.. i wrote code for a while but was mainly a sys admin - got a job that now i write code all day.. decided to go to school for it .. on one of the asignments the prof docked me for using a regex for finding links in pages instead of a fsm - because he didn't teach them in class.

    that pissed me off..

    --
    '...if only "Jumping to a Conclusion" was an event in the Olympics.'
  18. Re:Agreed! by orasio · · Score: 3, Informative

    Regular expressions have academic books behind them, and computer science books are written about them.
    Maybe what you talk about is nice, but REs (with extensions) are kind of ultimate solutions to the problem they try to solve (describing an automaton in a string of characters).

    The only thing that is needed to use another complete system is a theorem that proves there is a two way conversion between the system you like and REs, and then it would be fairly easy to implement everywhere.

  19. Snob by wsanders · · Score: 2, Insightful

    I dunno about the latest edition, but a large percentage of people I interview have a computer science degrees, are total dumbasses, and don't know a regular expression from their own ass.

    The more advanced the CS degree, sometimes, the more significant the dumassery.If you don't know what a regular expression is, at least admit to using a cookbook.

    --
    Give a man a fish and you have fed him for today. Teach a man to fish, and he'll say "WHERE'S MY FISH, YOU IDIOT?"
    1. Re:Snob by Jerf · · Score: 2, Informative
      My computer science degree taught me *nothing* about regular expressions. In fact, I would expect that any quality computer science degree wouldn't teach you about RE. Here's why: A good computer science degree teaches you one language, then it teaches you the concepts behind programming -- algorithim analysis, discrete math, data structures, fundamentals of programming on modern operating systems (threads, semaphores, etc), and once you learn all of the fundamentals, you are expected to be able to learn any programming language virtually at will.
      Very wrong, albeit with qualifications.

      Any competent Computer Science course should contain a discussion of the Chomsky Language Hierarchy. If you hold a computer science degree and that page is gibberish to you, you have been robbed. (Or at least, it should be familiar gibberish, for those who didn't like that course.)

      Regular Expressions come up in that course because the languages they are capable of describing are provably isomorphic to the languages that can be recognized by a Finite State Automaton, another word you ought to know if you have a computer science degree.

      The "qualifications" mentioned before is that the Regular Expressions in this case are a very limited, precisely-specified language that forms only the barest shell of the Regular Expressions that the book in question discusses. (The mathematical definition is practically useless, because very simple things like "i{0,50}" translate into a horrific mathematical RE, but most RE features can so be translated and many homework problems consist of doing just that, just to prove it can be done.) Nevertheless, it is important to understand these limitations so you don't press Regular Expressions to do something they can't really do, like entirely parse Context-Free or Context-Sensitive languages, like most programming languages (at least mostly) are.

      (It is true that some extensions, especially those found in perl, push the regular expression into Context-free or Context-sensitive territory when used correctly, but generally speaking, you're really asking for one disaster of a Regular Expression. You're better off using a parser. Perl 6 has some interesting innovations on this front, essentially building on their regular expression support to upgrade the language to built-in parser support, presumably at least the context-free level, perhaps more. I don't know.)

      It is true that a Programmer degree may not cover regular expressions, but you absolutely should have at least seen the mathematical basis for a Regular Expression in your Computer Science course. At Michigan State University where I got my education, it is, IIRC, in the sophmore course on the theory track.

      The language hierarchy is one of the absolute fundamentals of computer science.
  20. A poorly stated case by fm6 · · Score: 4, Interesting

    So regular expressions are evil because they're too hard to maintain? If that's you're argument, you need to come up with an alternative that isn't time consuming to code and doesn't require advanced skills that are difficult to master. Good programmers don't hand code fancy solutions any more often than they have to. They rely on well-documented, well-tested language features and APIs. Which describes Perl regular expressions to a T, whatever their shortcomings.

    Anyway, Perl regular expressions don't have to be "line noise". That's just the way sloppy people are used to coding. Perl actually allows you to create a clearly formated regular expression in which the structure is pretty obvious, with a little commenting. It does this by providing high-level metacharacters, and by allowing you to use blanks for formatting instead of representing blanks.

  21. Re:New for 3rd Edition by c0rr1n · · Score: 4, Informative

    Mastering Regular Expressions, Third Edition, now includes a full chapter devoted to PHP and its powerful and expressive suite of regular expression functions, in addition to enhanced PHP coverage in the central "core" chapters. Furthermore, this edition has been updated throughout to reflect advances in other languages, including expanded in-depth coverage of Sun's java.util.regex package, which has emerged as the standard Java regex implementation. The languages covered in Mastering Regular Expressions include Perl, Python, Ruby, Java, VB.NET and C# (and any language using the .NET Framework), PHP, and MySQL.

  22. Re:Slightly offtopic, Regex related. by prostoalex · · Score: 3, Informative

    The Regex Coach - The Regex Coach is a graphical application for Windows and Linux/x86 (also usable on FreeBSD) which can be used to experiment with (Perl-compatible) regular expressions interactively.

    The Regulator - The Regulator is an advanced, free regular expressions testing and learning tool written by Roy Osherove. It allows you to build and verify a regular expression against any text input, file or web, and displays matching, splitting or replacement results within an easy to understand, hierarchical tree.

  23. Re:Maybe it's just me but isn't 515 pages too much by pizza_milkshake · · Score: 4, Funny

    The last 300 pages are actually a single regular expression.

  24. Re:question for the floor by gerbercj · · Score: 2, Informative

    This book is not not really to teach you how to write regular expressions. This book teaches you to understand how your regular expressions will be parsed so that you can understand the impact of your approach and start creating expressions that are much more efficient, or that handle special cases more elegantly. It's the book that, in my case, took my skills to the next level. I still refer to it a few times a year, and am glad that it's a part of my library.

    --
    The weird part is that I can feel productive even when I'm doomed.
  25. Re:Maybe it's just me but isn't 515 pages too much by morcego · · Score: 5, Informative

    You are obvious a newbie regarding regular expresions, based on your post.

    First, 515 is not too much when talking about regular expressions. There is much to be discussed, not to mention tips&tricks to give away.

    Also, you are deadly wrong about the "small web page". First, it only talks about Perl Regular Expressions. There are other kinds, including the classic (basic?), extended, posix and (from your reference) perl regular expressions. Mastering the different kinds is enough to fill 300 pages of the book.

    Where are you going to use REs ? sed ? VI ? perl ? php ? C ? SQL ? You need to know what flavor of REs you need for that particular environment.

    Regular expressions is a very tricky topic, and understanding them is not something easily acomplished. Come to think about it, 515 might not even be enough.

    --
    morcego
  26. Re:Third Edition? Already? by Catamaran · · Score: 2, Funny

    Thanks for clarifying. I thought your post was a subtle play on RE's, Bill Clinton, and Max Headroom!

    --
    Test 1 2 3 4
  27. Regular expressions for geeks by MobyDisk · · Score: 3, Funny

    I am glad to see this on Slashdot since regular expressions is an area that geeks could really use help in.

    For example, instead of saying the common geek expression "Greetings Program!" try a more regular expression such as "Hello Sir" or the more casual "Wassup?" IRL, Tron references are not considered cool. Another common faux pas is using the expression "Hey n00b, what's your function?" instead of something more regular like "Hey dog, what's your problem?" If someone tries to threaten you, think about their technical skills before saying "Close your port before I pwn j00!" Life is not an FPS. "Shut up before I kick your ass" works very well.

  28. Topical plug: Regex Powertoy by gojomo · · Score: 3, Interesting

    Give a try to my web-based tool, Regex Powertoy. Its interface is all DHTML/CSS/Javascript, but requires a hidden Java (1.5) applet for the advanced and steppable regex engine.

    Given that Java core, there are options for adding/removing usual Java literal escaping, which in Java code means lotsa backslashes. Not all Perl advanced features are supported.

    I hadn't considered a pick for awk/sed/bash syntax limits/conversion but will consider it. Any handy reference to how their syntax differs from Perl/Java? (The thing that usu. bites me with sed is escaping of parentheses.)

  29. Stating the obvious by teslar · · Score: 2, Funny
    It's a good review and the book's great and all that, but I still had to cringe when I read this:
    there is no doubt that the regular expressions are the stars of the show around here.
    You don't say... in a book called 'Mastering Regular Expressions', that must have come as a real surprise...
  30. people look at you funny by schlick · · Score: 3, Funny

    Years ago I was calling around to bookstores looking for this book. A few bookstore employees asked me if it had a lot of pictures. They thought is was a book for people who have trouble communicating. Like knowing when to say,'hi' vs. 'hello' or somehting. sheesh. Now granted many people who read this book may be socially challenged, but this book won't help that.

    --
    "It's because they're stupid, that's why. That's why everybody does everything." -Homer Simpson
  31. I'll say it again by pvera · · Score: 3, Interesting

    I bought this book years ago and still can't STFU about it, sorry.

    At my previous job (web-based custom market research) we did hundreds of web surveys which had on the average some 400 data points per survey. These had distinct variable names, etc. and were built 100% by hand when I was hired in the company some time in 2002. My first survey project was a disaster, it took me about 20 hours from the final approved survey document to the dynamic version. The process was riddled with manual steps that created an infinite amount of room for errors.

    Enter regular expressions.

    While fiddling with BBEdit Pro I finally decided to take a shot at regular expressions. After an hour or so of experimenting I started writing a few filters that allowed me to cut down the turnaround from 20 hours per survey to a little over 10 hours. When I got to the point in which I wasn't able to figure things out from the BBEdit documentation and he web, I convinced the boss to buy me Mastering Regular Expressions.

    Within the first 50 pages, I had picked up on additional regular expressions concepts that allowed me to eventually cut down the turnaround per survey to less than 8 hours. That's not 8 hours programming, that's 8 hours from the moment the approved survey is handed over to programming to the moment it passes QA checks and is considered ready to go live.

    This was a $50 or so book, and it saved us thousands of dollars over the four years I worked at that company. Of course, my reward for saving the company all that money was to lay me off, and I "forgot" to leave instructions on how to use the text filters, so I imagine my replacement is right now writing surveys by hand.

    Some of the things that proved to be killer uses for regular expressions within that context:

    1. The approved survey would have specific variables that the analysts would need to keep for importing into SPSS later down the process. A text filter picks up those variables and generates a unique list of every variable needed for he survey. The variables are named with specific patterns, so you know which ones are strings, integers, etc.

    2. Now that we have a list of variables, it means we can quickly generate the CREATE TABLE statement for the survey data. What used to be done by copying and pasting 400 times is (was?) now done by highlighting the text and running a macro. The output is the SQL command you need.

    3. Since you already have the list of variables, you can generate the 400 statements needed to read each form variable into its proper variable in the asp code.

    4. The same way you can generate the hidden form fields that you need.

    5. The same way you can generate the INSERT statement to send your data to he database.

    Little things like that. Eliminating all that copying and pasting really cut down on the QA overhead per project.

    --
    Pedro
    ----
    The Insomniac Coder
  32. Re:stay away from regexes by StimpyCat · · Score: 2, Insightful

    Regular expressions are a fantastic thing to use in development and are perfect for data validation. I needed to parse huge csv files and filter out all the bogus values in certain colums. Without regex this would have been a nightmare. I used a csv parser to break all the tokens up and then regex to validate. Everything has its place, you must learn to embrace change not deter others from using it because you wont learn it.

  33. Re:For Programmers? NOT! by phazer · · Score: 2, Informative

    Well, I hate to say it, but I agree with the Prof. There are really two worlds in computer science: academia and work.

    Pretty much _all_ assignments that will be given in CS courses can be solved quite easily by using a library that implements a solution. In the working life, that would be the proper solution, but not so in school.
    Of course you can just call a class in your standard library that implements regular expressions and solve a problem that way. But that's not why you're in college. You ALREADY know how to call a library that someone else wrote. Calling libraries is trivial, you can pick that up with a few pages reading and some practice. The Professor isn't there to teach you how to call libraries though. What you're supposed to take away from the class is the understanding of how the class does the work.

    Finite state machines are the underlying theory of regular grammars (See: Chomsky hierarchy of languages.) So if the class covers how FSM's work, and what their usefulness is, then you should try to actually apply that knowledge to the problem. The assignment isn't so much one of "find the answer" (nobody cares about the answer) but one of "apply the theory" and learn something new.
    One day you'll find come across a similar problem that is very similar to regular expressions, but not quite like it, and you may remeber this assignment and write a FSM to solve it, and you'll be glad for it.

    It's like you're learning about sorting algorithms, and then you come along and use Collection.sort() instead of writing your own quicksort (and understanding the algorithm while you do so.)

  34. Re:Maybe it's just me but isn't 515 pages too much by chromatic · · Score: 5, Insightful

    You've mastered an entire field of computation by reading a short introduction to one implementation? I think I've fixed your code in about a dozen different companies!

  35. Re:Third Edition? Already? by onlyjoking · · Score: 2, Informative

    No need for the 3rd edition unless you desperately need the extra 40-odd pages on PHP regexes. That's the only difference between the 3rd and 2nd editions as far as I can tell.