rank trend

Mastering Regular Expressions, Second Edition

by Jeffrey E.F. Friedl
Released 2002-07-15
Read articles about Python
Buy it from AmazonNow

135 Reviews

Sort by: Most Helpful ▲ Date Rating

5 stars I need more stars... Bravo Jeffrey

2001-12-09     107 of 115 found this review helpful

Jeffrey Friedl's "Matering Regular Expressions" does a facinating job in taking you through the jungle (and I mean jungle) of RegExp.

I am a Perl/CGI programmer, and I had considered myself good at RegExp even before I read this book. Most of the things I knew were from Programming Perl, 3rd edition (chapter 5, Pattern Matching). But I still decided to give Jeffrey a chance since I was having some trouble with my Parse::Syntax module, which is designed to parsing *any* programming language and highlighting the syntax accordingly (provided it has a syntax/grammer file written for the specific language). The accuracy of the parser (and more importantly the speed) does depend on well crafted regular expressions.

As I started reading the book, I couldn't stop. I took it to my school's cafeteria with me and no one could make me leave untill I finished the whole book. I was excited. I was pleased! Here is the outline of tha chapters:

Chapter 1 and 2 introduce you to regular expressions and give some basic regex examples. Mail utility and date matching is two of them.

Chapter 3 mostly talks about conventions that all the regex tools follow and their differences.

Chapter 4 deals with Traditional NFA, POSIX NFA and DFA regex engines and their pros and cons. What you'll like the most is the details provided by the author on each and every single example. He also uses a lot of step-by-step illustrations to take you deeper into the regex engine itself and see/feel how it works. He shows the point of backtrackings and provides awesome benchmarks. He uses such examples of matching a quote, allowing escaped quotes inside the pattern, matching C-style comments, IP addresses and many more.

Chapter 5 deals with writing efficient regular expressions for NFA engines. It also re-vists some of the examples provided in the previous chapter and fine-tunes them.

Chapter 6 and 7 deals with Tool-Language specific features of Regex engines. Chapter 6 is dedicated to Awk, Tcl and GNU Emacs, whereas chapter 7 is entirely dedicated to Perl, good over 100 pages of Perlism.

It's true that there're features that Perl 5.6 offers when it comes to regex that didn't exist at the time this book went to press, (lookbehinds, for example). But this no way makes this book dated. Just take my word for it. Jeffrey put together a great masterpiece that will not die for many years, no matter how fast the technology tends to enhance
Haven't read anything more exciting than this for many years.

3 stars Great book with problems

2000-11-21     53 of 87 found this review helpful

I haven't read the book from cover to cover but have read parts of it. I don't deny that it is informative and occasionally helpful (especially if you come from a perl background). But the book as it stands is not appropriate for someone starting out in regular expressions. Instead it provides a lot of depth as far as how regular expressions are used in specific tools and all the different standards for regular expressions.

But a lot of this information on regular expressions is not relevant or necessary for composing plain vanilla bash regular expressions. I suspect that the majority of readers will find a few chapters helpful, but will skip over at least a few chapters that have no bearing on their work. To spend so much time in a book talking about the different implementations of regular expressions is to beg the question about whether you should read a general book or instead read a book about the implementation of r.e. specific to your computer language.

I have two complaints. First, the book does not try to teach you the art of writing regular expressions (it assumes a certain level of familiarity already). As a learning book, it may not be satisfy your needs. The second complaint is that the book doesn't include an adequate reference section or at least a section you can refer to when trying to write your own regular expressions. I found myself flipping back and forth from pages to try to find the aspect of regular expressions I need. A more methodical reference chapter or appendix is sorely needed.

Don't get the impression I am not recommending this book. It is a fine book; only be sure that you thumb through it at a bookstore to make sure that the kind of material it presents is what you are looking for. For me it was not.

The best teaching book I've found to explain regular expressions is Practical Guide to Linux by Mark Sobell. It's old, but it explains regular expressions, sed, awk and grep better than any book, including this one. This book presented the clearest examples of any computer book I have encountered.

5 stars Those wise birds!

2001-05-03     33 of 33 found this review helpful

I got Mastering Regular Expressions in 1998 and I peek back regularly and it am proud to say is one of most used and useful books I own.

Regular expressions are for everyone. They are simple to write and can be close to impossible to read and even unimaginably harder to understand. But reading comes after you can craft one.

And this art of crafting RE is explained in astonishing detail and analysis in this book. Reader is carefully guided through basics, differences and common and uncommon pitfalls. Some of the parts are definitely not for the faint hearted! And this is especially true for parts that cover Perl RE. While main topic is Perl RE engine, a deep-enough travel through different RE dialects is made to help RE-crafting in almost any tool that supports REs.

I've used the methods described in the book in tools as different as MS VC++, various editors, search engines and programming (Perl, PHP, C++, ...). The ability to use RE usually impressed people to the point they were sure I am using some incredible magic.

But I must say that the most useful feature delivered in this book was ability to PARSE, UNDERSTAND and FIX a (slow, broken, strange acting) RE. This can be slowly absorbed by reader's (open) mind while carefully reading the book. The difference between meant/written can be as extreme as it can get in RE. I can (proudly) say I've been able to fix several complex REs, by simply (one could say blindly) following the rules laid in the book.

My opinion is thath without this book real understanding of RE is almost impossible. I recommended it all of those who use programs that support (any form) of RE engine. It will help them solve some (hard) problems incredibly fast!

5 stars Simply Outstanding

2002-09-26     31 of 33 found this review helpful

I bought this book on a whim, mainly because I try to buy (and read... ugh!) a hard-core technical book every month or so, but mainly because my UNIX scripting abilities have become rusty with disuse. I used to be able to write a tight, 10-line csh script to mangledit thousands of files at a single time. Now I hack away at files manually with vi. The other day, I even forgot how to search & replace. My kung fu isn't nearly what it used to be.

It usually takes me about a month to slog through a new book (especially academic texts, which are great but make you want to have a stiff martini before each new chapter) but I tore through Friedl's book in a few days. It's an outstanding reference for understanding & learning to use regular expressions.

Regexes can be cryptic to say the least, but Friedl offers many examples, broken down into step-by-step instructions and explanations of how each regex works (in many cases, right down to the individual character level). He covers a variety of platforms and languages - the hardcore Perl enthusiast will enjoy this book greatly, but he offers fairly equal time to alternative languages like Java and the "grep" family.

All that said, this book is an outstanding technical reference, pure and simple, for two reasons:

- Friedl uses an interesting new typesetting convention to illustrate which sections of text are regular expressions, and which sections are not. It's hard to describe (and impossible to reproduce here) but they look like 90-degree braces at the upper-left and lower-right corners. This is a FANTASTIC approach and I for one would love to see this extended to other technical books.

- Speaking of other things I would love to see extended to other technical books, THIS BOOK HAS ALMOST NO ERRORS! This is even more impressive considering the fact that, with regular expressions, screwing up EVEN A SINGLE CHARACTER is significant. Nothing [upsets]memore than spending $50-100 perfectly good dollars on a sloppy, error-laden, grammatically-challenged, poorly-edited, ill-reviewed and badly-structured book (which pretty much describes 90% of all the technical books out there). He made a few mistakes, the vast majority of which are extremely trivial in nature, and all of which were quickly posted to his website as errata. If only the other 90% of the technical authors out there were even half as diligent.

All told, this book belongs on your bookshelf.

5 stars Learning Perl? Buy this first!

1998-02-07     31 of 35 found this review helpful

I made the mistake of buying a bunch of books on Perl to try to learn Perl programming. I made progress, but it was slow -- and it beat me down. Then I bought THIS book. Perl's implementation of Regular Expressions is a great deal of the functionality of that language. This is true to the extent that trying to read Perl script without knowing Regular Expressions is tedious at best. This is not just another computer book. Jeffrey Friedl has put his heart and soul into this work, and it shows. He even offers free updates (in the truest, most honest sense of the word) from his own web page. This is the best programming book I own.

After reading this book, Perl script reads like USA Today! Save yourself lots of heartache. Buy this book, Mastering Regular Expressions -- read it -- THEN learn Perl!
Jeff Morris

4 stars Will help you make sense of a daunting subject.

2000-06-07     22 of 24 found this review helpful

This is a book about Regular Expressions 'for Perl and Other Tools' but really it's a book about Perl. Other tools are covered, but coverage is a bit woolly, so if you are reading it to get the low-down on Python's RegEx capabilities etc. this book won't get you far. I can't help that feel that if the book had just concentrated on Perl, rather than giving sketchy coverage of `Other Tools', it could have been even better (and would have definitely got five starts). That said, the extra coverage (particularly the RegEx engine material) was very interesting and has turned out invaluable in practice.

If you are an absolute beginner to Perl or programming you will need another book(s) to get the most out of this one, but it is a gentle and thorough introduction that won't leave you scratching your head, which is a feat in itself considering the complexity of Regular Expressions.

This is an excellent book for getting the most out of Perl's RegEx capabilities, you will close the back cover feeling that you genuinely have Mastered the subject. It is without doubt the best book available on the subject, nicely written, with a friendly and un-patronising tone (grammatical errors aside), you can't really go wrong with this one.

There could have been some more useful real world examples/projects included, and the book could probably do with an overhaul (it was published in 97) to accommodate Perl 5.6 and other developments (O'Reilly are you listening?), but it is still the best out there.

If RegEx is a subject you need to get to grips with, this book is the solution.

4 stars Masterfully written; bit of overkill for nonprogrammers

2000-01-23     22 of 23 found this review helpful

Whether you are searching text documents with BBedit or flagging Usenet articles with Newswatcher, learning to use regular expressions can make your life a lot easier. Regular expressions ("regex") are text strings that allow you to search for complex variations of words and phrases. For instance, with the simple regex "gr[ea]y" you can flag any instances of the words "gray" or "grey". While a lot of applications support regex, finding out how to use this powerful function can be very difficult. There is suprisingly little online documentation of regex.

Friedl's excellent book fills this void. In the introductory material, he covers what a regex is and how to use the regex language to do your own searches. The rest of the book, however, is aimed at programmers only, dealing with how various programming languages (such as Perl) implement regex. If all you want to do is use regex for searching text files or flagging Usenet articles, most of the book will not be useful to you. However, until someone comes out with a pocket manual of regex, Friedl's book is the only game in town.

5 stars i wish all tech books were this good

2002-03-07     20 of 21 found this review helpful

I can't say enough good things about this book.

Regular expressions are such a powerful concept, but some of that power would be easy to miss if not guided correctly through the topic. Jeffrey Freidl does a great job of making a potentially very dry subject interesting, even while getting very involved in all the complexities that are inherent in such a powerful abstraction. He also does a good job of presenting both the general topic of regular expressions and the specific characteristics of the various tools available to process them.

This is a book that you will come back to many times. I actually read it as a precursor to learning Perl several years ago. Then just recently I revisited it while taking a class on compiler construction and found that it still had useful insights for me. If you're a committed programmer, this book should be on your shelf.

Also, the criticisms I've read in reviews here are pretty misguided. It is "chatty", because the author has a genuine enthusiasm for his subject. It is also not a "teach yourself regular expressions in 24 hours" kind of book. There are actually lots of cookbook style examples, but the main point of the book is to give you a solid enough understanding of the general topic that you don't need examples to craft your regexes. In this case, little patience as a reader will be much rewarded.

3 stars Don't fear the regular expression

1999-12-18     19 of 29 found this review helpful

One of the most frustrating things about learning the perl language is learning to deal with its regular expressions. This book does a great job of explaining complicated examples and has challenging problem solving situations. It covers mostly input manipulation, searching and filtering, which are probably the most important aspects of regular expressions. I give it 3 stars is because its a tad bit on the wordy side. O'Reilly books useually do a good job of explaining things, but there were many details about regular expressions that I could have done without reading about. There is a consistant lack of examples throughout the book as well. If you are going to throw a lot of complicated technical information at the reader, it is a good idea to illustrate consepts no matter how big or small. I can't say anything else negative about the book though, because if you are struggling with regular expressions I would recommend that you get it. After a few chapters you will have a better understanding and be writing your own confusing perl regular expressions.

5 stars PHP programmer says: EXCELLENT value! Everything's here.

2001-01-04     18 of 19 found this review helpful

If you are an intermediate-or-better PHP programmer who wants to get a handle on regular expressions, you'll find this book so incredibly handy. I'm only a few chapters into the book and already I get the gist of regexs and how to use them with PHP... plus the Perl examples are very, very clear (the author stays focused on regex, Perl is just used to put it in a program's context, so he explains clearly what is going on with each line and you can see how it would translate easily to PHP)... the first chapter of this book did more to explain regexs than spending weeks searching the web for a *clear* tutorial.

I suspect I'll skip most of the second half of the book-- after all, it's called "mastering regular expressions," and I don't really want to master them, I just want to be really good and then keep going with other stuff. (The author spends chapters looking at nearly EVERY regex tool out there, etc... which is not useful to me since I know I'm going to be using regexs 99% of the time in PHP.) If there is anything I could change about this book, it would be to put the first five-or-so chapters into a separate slim volume and *PLEASE* include a quick reference card for all the metachars! (that's my next purchase...)

But listen, if you want to LEARN regexs, this book does the job, the writing is crystal-clear, the mini-quizzes every few pages are excellent, the typographic conventions (used to really make the expressions clear) are clever and smart, and this book has EVERYTHING you will EVER need on regular expressions, in your entire life. Well worth the $; you won't ever need another regex book again.

2 stars Appallingly chatty and unprofessional style.

2000-04-06     18 of 35 found this review helpful

The author's unamusing cuteness is a constant distraction. In the single brief section explaining NFA vs. DFA regex engines, for example, we are treated to:

"We (humans with advanced neural nets between our ears) can see that if we're matching 'tonight,' the third alternative is the one .... Despite their brainy origins, a regex-directed engine can't come to that conclusion ...."

"What this really means may seem vague now, but it will all be spelled out just after the mysteries of life are revealed (in just two pages)."

"(You know, if I could find a way to include 'It's not over until the fat lady sings," in this paragraph, I would.)"

With phrases like this throughout the text (and even in the table of contents -- e.g. one section is entitled, "A Really Crummy Analogy"), one wonders how O'Reilly editors could possibly have OK'ed this immaturity.

The few uses I made of the index suggest many omissions and errors. "\A" for example cites only page 236 (Dec. 1998 printing), although no hint is offered there of its definition. "\c", for another example, is nowhere to be found. (It is incompletely explained in the text at p. 241.)

The index also reflects indifference to the reader's time and productivity. A high proportion of entries force a second lookup ("see ...") by not providing any page numbers themselves.

I found the discussion of subtleties involving matching with the "\G" Multi-Match Anchor clever and informative. The author probably knows his stuff and has things to say. Much of the guilt for the book's overwhelming defects can be laid at the door of the editors at O'Reilly.

3 stars Very thorough. Very Unix.

2002-04-03     16 of 24 found this review helpful

This book is a good follow-up on the 80 pages about Pattern Matching in Programming Perl (3rd Ed.) if you need to get into more detail. The book is really most useful to Perl programmers. It covers RegEx's in great depth and shares experiences which would take years to build up on your own. The book claims to cover platform-neutral tools, but the content of the book seems to be written almost solely from Unix experiences.

If you want to learn more about RegEx implementation on a non-Unix platform, chances are this book won't fulfill your needs. However, there are exceptions. The Microsoft .NET Framework e.g. is an implementation designed for compatibility with Perl 5 RegEx's (adding features such as right-to-left matching).

Buy this book if you're a Unix user and want to know all about Regular Expressions. Otherwise, think twice. It might be a bit too specific for your needs.

2 stars this book needs an editor!

1999-11-10     16 of 32 found this review helpful

On the internals of regular expression matching, this book is without equal. I found this book to be an excellent source of information on constructing efficient regexps in Perl.

Unfortunately, this book is also without equal when it comes to *poorly* presenting information.

The tables are unreadable -- visually impossible to decipher, cryptic, cluttered. Edward Tufte could use this as book as a prime example of how not to present information.

And it's a shame, because there's a wonderful book buried inside Mastering Regular Expressions.

If this book gets proper attention from an ORA editor, I could easily give it 5 stars. In its present form, it's nearly unusable -- 2 stars.

--Pat / zippy@cs.brandeis.edu

5 stars RE: Third Edition

2006-08-21     15 of 16 found this review helpful

§
The third edition just came out -- and that makes 10 years since this book was first published. That statistic alone indicates the steady value of "Mastering Regular Expressions" across the constant changes in applied software technology over that time. Regular expressions, still the most under-used power tool, needs a book like this.

Specifically, this third edition features enhanced coverage of PHP in the early tutorial chapters, plus an all new chapter devoted entirely to PHP regular expressions.

Also new in this edition, the Java chapter has been rewritten and expanded to reflect new features as Java itself has developed.
§

2 stars Don't call me a reference book

2003-06-02     15 of 48 found this review helpful

I found other books much more helpful on solving a sticky regular expression problem. The author himself sums up his attitude towards users who want to find the solution fast without reading his 'story'
"Readers familiar with regular expressions might feel that they can immediately begin using this book as a detailed reference, flipping directly to the section on their favorite utility. I would like to discourage that."

So, for anyone with a problem and you think your are going to flip to a section and solve it, sorry, the author says he discourages that and you must read his story first.

"To get the most out of this book, read it as a story first".

I would rather have an experienced expert focus on creating a book to solve problems, not show me how smart he is. And reference books should be writen as reference books and leave the stories to Tom Clancy.

5 stars So good, I bought it twice!

2003-01-05     15 of 15 found this review helpful

In spite of the vow that Friedl would not put himself (and his family) through the rigors of writing a followup to his first edition, I sure am glad he made the decision to write a second edition. Over 5 years ago, I got the first such book and found it to be a humbling experience -- realizing just how little I *really* knew about regular expressions (in spite of thinking my skills were quite advanced in that area).

Now, years later and as an instructor of UNIX at North Lake College in Irving, Texas, I highly recommend this book to even our first year students. Friedl's clear explanation of this topic and the manner in which he presents the material makes it comprehensible to even those that have never had experience with regex's before. Like Perl's Larry Wall, Jeffrey Friedl has a strong background in natural languages. That contributes not only to bhis lucid writing style but also helps in terms of understanding regex's as a "little language".

This 2nd edition is particularly welcome because of its extensive coverage of regular expressions in the context of Java. That ons aspect alone is sufficient to get the updated second edition (to say nothing of the enhancements in Perl since the first edition of the book).

5 stars Separates the players from the punters

2002-08-13     15 of 16 found this review helpful

Regular expressions help you "lex", or make sense of text input to your program in a method much more powerful than your junior college or MCSE program taught you.
In the mid '80's I wrote a lexer/parser/compiler as a class assignment. I definitely used regular expressions in order to break the input down into lexemes so I could generate object code. Back then, we learned regular expressions "the hard way".
This book makes learning them easier. You don't have to be writing a compiler in order to make use of regexes! Spam filtering is my current use for them.

2nd ed. vs. 1st ed.: He attacks the subject more seriously.
He (as far as I can tell) dropped "vi" coverage.
He uses Perl 5.8 for his examples, though has chapters for the most popular regex engines, including VB.NET.
Summary: I think it's easier to follow and more business-oriented than the 1st edition, though don't toss the 1st edition. You'll need them both.

1 stars Never has so much been made of so little

2000-03-23     12 of 43 found this review helpful

If you're looking for a handy desktop reference this book is NOT it. When faced with a short-fused development schedule and needing to get up to speed with regexps rather quickly I found the book to be difficult to navigate, inconcise, and the overuse of bold, italics, and foreign (Japanese?) characters and other oddities very annoying. I thought the book went way beyond regular expressions and therefore found it of little use as a reference guide. It is better suited as a tutorial for someone that has a lot of time on his/her hands. A much better reference, also from O'Reilly, can be found in "JavaScript - The Definitive Reference", by Danny Goodman.

5 stars Accelerated Learning!

2000-07-03     11 of 18 found this review helpful

Within two weeks after receiving Mr. Friedl's book, I was able to write a concise Perl regex (see below) to find arbitrarily complex bible citations (e.g., Is 1:4,27:6-10,65:1-66:1,5-15) in my bible study files. I'm not a programmer by trade or hobby, have no Perl background or any appreciable experience with regexes thru grep or similar tools (my background in data modeling using EBNF helped me grasp the regex concept). Mr. Friedl's orderly and thorough progression from simple to complex material allowed me to easily tailor my reading and "practicum" towards a specific problem, while learning a great deal about regexes (and Perl as well, although this is not a Perl book). Mr. Friedl's humor helped keep my interest, although that's purely a matter of taste. I strongly recommend this book if you're looking to go from 0-60 mph on regexes, both conceptually and practically, within a couple of weeks. If you're looking for "recipes," you'll be disappointed.

/$bk\s*($ver_rng+|$ch_rng+)+/g

1 stars Poorly assembled time waster

2002-05-21     10 of 76 found this review helpful

I found little use for this book and I think any moderate to average perl programmer would have no need for it.
The book itself is much too long and full of uninteresting fluff that only a few really lonely will bother to read. Luckily I didn't have to waste any money on this book, and I urge you not to waste yours.
A book on this subject could have been interesting and helpful, but Jeff Fried ensures that you will get no joy nor use from reading it.

5 stars Eureka!

2001-12-01     9 of 10 found this review helpful

Okay, so maybe I'm no Archimedes, but this book suddenly illuminated the world of regular expressions for me. I'd toiled through three or four other books, some of them pretty good, without getting it.
After just a few chapters of this one, I can finally say that I understand regular expressions and can use them to my advantage instead of just being vaguely aware that there is a better way to do what I've been trying to do.
Don't wait, buy it now!

2 stars verbose and over rated

2001-03-23     9 of 28 found this review helpful

I got this book because it was highly recommended by two PERL experts, Tom Christiansen, and the author of EFFECTIVE PERL.

But this 300 page book is written as if it were a novel and not a technical book. It could easily have been half the length, and I'm not exagerating. The long chapter on how NFAs & DFAs work will be of interest to few people.

I expected to learn all sorts of cool tricks via regular exppressions and was dissapointed. Sure there are a few good examples, but at far too high a price in time involved and money.

This book will only be of use to the very few people who are really into NFA theory. For most people, this is a wasteful book. Its possibly the worst, least useful technical book Ive read.

4 stars Best Title on the Subject

2006-08-28     8 of 11 found this review helpful

If you have ever been frustrated trying to figure out Regular Expressions (RegEx) based only on a table showing symbols and a few paragraphs of explanations obviously written by someone who assumes you are already familiar with the concept, then this book is for you. Don't be daunted by 480+ page size of this title; before you reach the end of chapter 2 you find yourself with a solid understanding of the concepts, structure, syntax and "keywords" in common use by those utilities, programming languages and applications that incorporate RegExs. The middle of the book covers implementation of RegEx in different environments, techniques for creating the expressions, and methods for creating efficient expressions. The end chapters are specific for Perl, Java, VB.NET and PHP users.

The only minor issues I had was in the tools used to demonstrate the concepts. Although no tool used cost the reader money if they wish to hands-on follow along, some of the downloads are from third-party sites which have no guarantee of offering the download by the time you get the book. Additionally, the author makes heavy use of Perl to demonstrate RegEx in scripting, which is fine for Perl users, but those that use other languages to fend for themselves. Seeing additional examples in other free languages, such as VBScript or JScript would have been nice.

Overall, Mastering Regular Expressions is an excellent choice for both learning the basics as well as better preparing yourself to apply them in real-world situations. The writing style is easy to understand and follow, and the layout allows this book to be a learning resource now, and a decent general reference later.

4 stars Comprehensive Guide to Regular Expressions

2003-05-28     8 of 8 found this review helpful

Most computer programmers have heard of regular expressions, discussed in hushed tones and conjuring images of Unix gurus and their incomprehensible commands and godlike mastery of their systems, yet few actually know enough about regular expressions or how they work to do more than a simple word match using one, if that.

This book covers regular expressions from top to bottom in great and exhaustive detail, including the hows and whys of performance and supported features between the different engines that process them. Though geared mainly toward Perl, the examples and text will apply to nearly any system that provides support, from PHP to ASP to Python.

The text is fairly dense and is not exactly geared toward the novice programmer, though. I've had classes in Finite State Machines and still had to really apply my grey matter in a few spots to understand everything being discussed. However, the understanding the reader gains upon completion of the text is invaluable and will expand one's programming potential exponentially.

The one real lack of the book is a good overview and quick-reference card, but on the whole, the book is a good selection from the O'Reilly library and well worth the read of any serious programmer.

5 stars The definitive guide to regular expressions

2003-04-27     8 of 9 found this review helpful

Regular Expressions ("regexes" for short), have been officially integrated into Java with the release of J2SE 1.4. While many Java developers are just discovering them, they have been a fixture in other languages and tools for quite some time. Regular expressions are powerful tools for performing all kinds of text processing, but they require no small amount of knowledge to use effectively and efficiently. This is where "Mastering Regular Expressions" comes to the rescue.

The book's nine chapters are categorized into three sections. The book first teaches the basics of regular expressions, crafting simple regexes, and the different features and flavors available in various regex packages. Next, the reader is given invaluable information about how the different types of regular expression engines work, as well as techniques for crafting practical and efficient expressions. The final section covers language specific issues in Perl, Java, and .NET.

The author does an outstanding job leading the reader from regex novice to master. The book is extremely easy to read and chock full of useful and relevant examples. The author offers up questions along the way designed to engage the reader to apply what he has learned. In-line references to other parts of the book containing information pertinent the particular topic being discussed are also very helpful.

Regular expressions are valuable tools that every developer should have in their toolbox. "Mastering Regular Expressions" is the definitive guide to the subject, and an outstanding resource that belongs on every programmer's bookshelf.

5 stars I wish I could give it 6 stars!

2002-12-30     8 of 8 found this review helpful

The book is a perfection! Everything is excellent here: style, accuracy, language. Jeffrey managed to give formal and complete coverage of formal parts of regular expressions together with detailed explanations of WHEN and HOW certain expressions should be used in real world.
Use of regular expressions can turn into a mess because usually there are many ways of mapping given task to regular expressions. When going through every practical task, Jeffrey Friedl carefully explains what variant should be used and why. To let readers check their understanding, author often puzzles them with brief tasks that readers are supposed to solve and verify the answer on a next page. I enjoyed every puzzle, and it really helped me to master my skills. While still reading the book, I was able within a few hours to write a simple RE-based parser for my work.
Highly recommended!

5 stars Understand Regexes

2000-04-18     8 of 8 found this review helpful

As somone else said, "If you're looking for a handy desktop reference this book is NOT it." But it doesn't claim to be. The title is "Mastering Regular Expressions" and that's what the book is for. If you want a quick reference so you can just find a regex to do what you want, then you're not interested in mastering regular expressions, are you? This book is for someone who wants an in-depth understanding of regexes - not someone with a looming deadline. This book is in the category of "Teach a man to fish, and you've fed him for a lifetime."

5 stars Finally an instructional book that actually teaches!

1999-01-06     8 of 8 found this review helpful

Jeffrey Friedl is one of those rare authors who actually knows how to teach instead of simply trying to impress people with his knowledge, as so many authors try to do. From cover to cover, he takes a thorough, methodical approach to regular expressions and doesn't leave ANY stone unturned, makes NO ASSUMPTIONS about his readers' knowledge, and leaves NOTHING to chance. He is completely knowledgeable about regular expressions and genuine in his desire to pass this knowledge to his readers. Anyone new to regular expressions will have gotten their money's worth by the time they finish the second chapter. Now I just wish someone would pay Jeffrey Friedl to re-write half the computer books on my reference shelf! Authors take note! We don't care how smart you are - we measure you by your ability (and sincere desire) to pass this knowledge on to us! Jeffrey Friedl sets the standard with Mastering Regular Expressions.

5 stars Mastering Regular Expressions

2006-08-23     7 of 7 found this review helpful

I've corresponded personally with Jeffrey Friedl several times over the last few years, and I remember being at once impressed with his attention to detail and his focus. I was invited to be one of the technical review editors for this third edition of his authoritative book on Regular Expressions, but had to pass due to time constraints.

However, I am pleased to state that whoever the tech reviewers were, they did a thorough job on this one from O'Reilly. This book has matured over these three editions to become what I would consider the most detailed and valuable book about Regex on the planet - and that means whatever your favorite programming language or platform is.

You see, Regular Expressions is in itself a language, and transcends programming languages and platforms because the concepts are basically the same across all languages - whether it be Perl, JAVA, C#, Visual Basic, Javascript, PHP, Ruby, Python, TCL - you name it.

And this book focuses on the mastery of regex, not being a reference tool. Though each language has a different syntax for handling objects and methods, the underlying objects and methods are the same with Regex, so even complex examples shown in one language directly translate to the other languages.

Suffice to say that there are basic concept chapters that are really language - agnostic, and then specific sections on PHP, .NET, JAVA, and Perl. The book covers practical Regex techniques and most importantly, it gets you to the conceptual level where you can begin constructing Regex patterns on your own, without having to look for "examples".

For .NET developers, Jeffrey provides a complete table-based overview of .NET's Regular Expression flavor, with a focus on the new features available in .NET 2.0, including class subtraction, RegexOptions, and named capture.

In sum, let me just say that any developer who finds the need to manipulate text - whether it be scraping a web page, creating a report, importing data, or a hundred other applications, is going to need Regular Expressions. Jeffrey's book provides a complete and mature approach that is fresh, timely and detailed. I would recommend this book for any developer.

5 stars The Bible of RegEx

2004-04-30     7 of 7 found this review helpful

One of the hardest things, even for a seasoned programmer to grasp is regular expressions. They are powerful ways to search, manipulate and parse text fields and can often take several lines of code and shrink it down to a mystic, but powerful, expression.

If you have ever had to parse a file for information, you know that one of the things that still haunts any programmer nowadays is how to match text. In this day and age of Object Oriented Programming, Web Services, etc. the power of Regex holds firm.

Throughout this book the author takes great care not to overwhelm the reader with tons of code that has no meaning. The power of the book comes from the fact that if you read, and follow along, through the examples you will gain an understanding of how to do the techniques the author is referring to. At times it may seem like you have to read over a section twice, but you will realize that as you carry forth into the next section the material you read previously has turned into something you can now apply -- not just another example you can cut and paste and never really learn technique behind.

This is a powerful book, covering many, many pages. Noone should expect to sit down and read it cover to cover and be done with it. The benefit comes from reading, applying, and referencing. I find myself using it several times a week to lookup information on Regular Expressions and to held solidify knowledge of techniques that I have used in the past.

Whether you are a Windows, Unix, or even Macintosh person -- RegEx holds the key to text manipulation -- and this book holds the map you need to find that key.

5 stars A necessary volume for any serious perl programmer

2001-08-01     7 of 9 found this review helpful

There's not much to say about this book, really; like any O'Reilly book, it distills a lot of useful information into a compact, useful book. Any serious perl programmer needs a solid understanding of regular expressions, and this is volume to get it from. The best endorsement I can give this bok is this: Unlike a lot of perl books, we don't share this one in my office- we all have our own copy.

5 stars Mastering Regular Expressions - A must-read for any savvy power-user

2007-01-17     6 of 6 found this review helpful

For many savvy computer users, regular expressions embody the perfect utility: a well defined, documented, and designed tool that makes complicated and arduous jobs short and easy. That being said, the craft of regular expressions (hereafter, `regex') makes about as much sense as a foreign language to the uninitiated or novice. Regex have no immediately apparent meaning to those unfamiliar with them, and are so enigmatic in appearance that many users do not even attempt to understand them - writing them off as a tool only for experts. "Mastering Regular Expressions" sets out to not only make regex understandable, but easy to apply to a wide range of situations.

Stylistically and structurally, this is one of the most unique O'Reilly publications I have read. The author even says in the early chapters to think of the book as a novel, and not as a reference (the book's structure doesn't really lend itself to being a reference book anyways). The mindset that the author applies to his writing makes a discernable difference in how the book reads, and it feels more like a chronological story and less like a textbook as a result. Even the quizzes that the author scatters throughout the book are treated as part of the "story", and the solutions are on the very next page rather than in the back of the book or at the end of the chapter. As a result, the book is very easy to read, and flows extremely well. It feels much less like a textbook and more like a narrated lesson from an enjoyable professor.

With a topic as muddy and potentially confusing as regex, I was worried that the text would be just as confusing to follow. However, I was pleasantly surprised. The text itself is very well written, and very clear. There was never an instance in which I had trouble comprehending what the author was trying to communicate, and I almost never had to go back and re-read something multiple times to grasp the concept.

Furthermore, the text is full of excellent examples with accompanying explanations. The author almost exclusively teaches through example, and as a result, most of the lessons are extremely practical and great real-world applications. All of the code examples (of which there are many page-long instances of) are very well documented, and easy to understand.

Regex really is one of the most portable utilities that exists in the UNIX world. It can be applied to an enormous number of situations, and is interoperable with a laundry list of other tools and languages. As such, regex is not only a tool, but a general concept that must be grasped prior to proper usage - and this is what the first several chapters focus on. Thinking about problems in terms of regex is something that takes practice, and does not come easily to most people. This book tends to teach through example, and jumps right into matching simple regex to text lines to demonstrate how regex works. This brings me to my next point.

This book is not for beginners. I cannot stress this enough. The chapters not specifically aimed at a language require solid knowledge of a structured language like C++ or Java. Granted, the book really won't appeal to anyone that doesn't use computers on an advanced level on a regular basis; however, what I want to stress is that regardless of the reader's level of computer experience, if the reader does not have advanced knowledge of text handling in serious computer languages, most of the book's content will be too complex.

On the same note, and this is not a bad thing, about half the book is language-specific. There is a chapter for Perl, PHP, and Java. Obviously, if you don't know these languages, then most of the content of these chapters will be useless. This is not to say that the book will be useless to you if you don't know these languages - the non-language specific chapters occupy a large portion of the book, and contain more than enough material to master regex - however, the reader should be aware that just under half the book is aimed at specific languages.

Overall, this book is nothing short of fantastic. The audience for it is very limited - however, the author manages to make a concept difficult to understand, and even harder to master, easy to read about and learn. Clearly, a lot of thought went into the craft and design of this book, and it shows. I would highly recommend this book to any programmer, system administrator, or computer power user.

5 stars Great Regex Book

2005-09-29     6 of 7 found this review helpful

I have known about regular expressions for a long time, but they have always been some kind of mysterious secret code. Recently I was reading something else that pointed out the power of regular expressions, so I decided it was time to learn regular expressions once and for all. After reviewing the available books on Amazon, I chose this one. I was not disappointed.

After reading just the first few chapters, I have been able to put them to work and make my life a lot easier. As a software engineer, I'm always doing searches through code or search/replace operations. I am now able to do more precise searches and do search/replace operations I never dreamed were possible before.

Learn regular expressions now! Get this book!

5 stars The Bible Of Regular Expressions

2005-06-09     6 of 6 found this review helpful

Back in 2000 I had to complete some task and another engineer said "Use a Regular Expression". Ignorant of what a regular expression was, I got a quick explanation from the programmer who brought it up, and then I quickly got Perl to do what I needed, learning how powerful regular expressions are. Regular expressions are like that magical elixir, that wonderful little secret that was created to fix specific little problems, and man when you need them, they do the job better than almost any other.

If you are reading this review, you probably have some background as to what regular expressions are, but in a nutshell, they quickly let you find a particular search string and then modify it as needed. Regular expressions have their own ruleset as to how these searches/replacements are performed, and in order to learn how to write good RegExs, you need the book 'Mastering Regular Expressions'. You will not find a Regular Expression reference as good as this book by Jeffery Friedl, and I challenge you to look for yourself!

If you ever need to parse through a lot of data, whether it be logs or just finding a particular piece of code, you will save yourself a lot of time and gain much in performance by learning how to use Regular Expressions to accomplish the task(s) at hand. Having this book by your side will make that journey all the easier, and you will find lots of great examples pre-written, and new approaches as to how to write better RegExs to complete your tasks by having this text by your side. It's binary folks, if you use RegExs in your line of work, you need this book, you will not be let down!!

***** HIGHEST RECOMMENDATION

4 stars Excellent book for experts++

1999-11-19     6 of 6 found this review helpful

This book gives you an excellent and detailed understanding of the concept and the various dialects of regular expressions. Once understood you should be able to follow and develop regexes on any machine with any language supporting regexes. There are plenty of examples, teasing your knowledge and keeping you practicing. One of the best parts, I think, are dedicated to understand when a regex is (time-)efficient - and when it can not be. However, it may be too puzzling for beginners. E.g. if you started with Perl perhaps you'll find enough about Perl's implementation of regexes in Schwartz'&Christianses "Learning Perl" for a while.

3 stars No summary or synopsis, only good for thorough detail.

2005-10-21     5 of 11 found this review helpful

Get the small pocket reference guide instead of this book! It is difficult to find what you want if you don't know exactly what you are looking for. I admit it covers the subject very well, but if you don't know Regular Expressions thoroughly, you have to read every word of the book or look forever to find what you want. Just buy the pocket reference guide and go to the library once a year when you need this thing.

5 stars The regex bible

2005-10-10     5 of 6 found this review helpful

The only book to explain regular expression in a clear and exhaustive manner, covering differences between the most important programming language in which regex are used.

A "must have".

5 stars Great book !!

2002-10-29     5 of 6 found this review helpful

This is a great book about regular expressions. Excellent for beginners, programmers and as a reference. The book contains lot of examples... and covers issues like searching in HTML documents, matching balanced set of parantheses, continuing with continuation lines, parsing csv files, doing search and replace, searching backwards, matching IP-addresses, file name checking, handling escape character etc.

It covers regular expression API's in a many programming language API's. There are separate chapters on packages for regular expressions in Perl, Java and .NET framework. There are some useful comparisons among various packages available in each language, which might help getting started on right track.

The book is very well written and is easy to read. Probably it contains the most extensive documentation of regular expressions. It also describes some regex usage in applications like grep, emacs, awk, egrep, sed..

4 stars Amazing!

2001-01-08     5 of 5 found this review helpful

I have almost all of the O'Reilly Perl books, and they're all fairly complete -- but it would be impossible to be complete in one of those books when it comes to Regular Expressions. This text is a must-have for anyone using Perl or even object-oriented JavaScript, as it covers regular expressions in exhausting detail. If it isn't covered in this book it doesn't exist!

5 stars Useful, enlightening, perhaps even entertaining

2000-05-26     5 of 9 found this review helpful

In my opinion, one of the two best books from O'Reilly during the 1990s (the other being the original 1991 "purple camel book"). Friedl applies his perfectionist and completist nature fully to the task. He did his own layout, which is not that unusual in the technical publishing trade, but which definitely isn't the O'Reilly way. The book is better for it (probably much better) and for all the other places where his attention to detail and thoroughness takes command.

This book is not a good end to end read, but it goes very well if you read some of the beginning material and then read a page or three from time to time as you get a chance. I sometimes (only half jokingly) suggest to my students that they should replace their copy of Reader's Digest near their "thrones" with a copy of MRE. Then they can read about a new topic for 10 or 15 minutes and ponder it for the rest of the day, which, if you are new to the theory and reality of regular expressions, is about the perfect regimen.

4 stars Don't Assume You Know About Regular Expressions...

1999-11-09     5 of 6 found this review helpful

...as I did just because I took "formal language" and "computation theory" courses at a university. I laughed when I first saw this book in a bookstore years ago, because I imagined the content must be so elementary. Until I actually started reading the book a few weeks ago, I thought all regex engines were essentially what this book refers to as "DFAs." As the author clearly explains, DFAs are "fast, consistent, and boring," while NFAs, the type of engine that most tools actually use, are more powerful but also much trickier to use.
The book focuses on using regexes to do useful tasks with real tools. The efficiency of the various types of regex engines is explained, since a slight change in a regex can cause several orders of magnitude slowdown with some engines.
While I do agree with the author that "DFA matching is boring", I wish the author had included some discussion of how a state machine can implement a DFA regex for some insight into how DFA engines work. I also wish there had been exercises at the ends of the chapters, in addition to the few questions and answers scattered throughout the book.

2 stars Real disappointment on "Perl Regular Expressions"!

1998-10-12     5 of 15 found this review helpful

The author should NEVER adovacate programming with readability(abstraction) and efficiency at the same time. Taking advantage of the perl internals(implementations) for the purpose of optimization in regular expression matching is the worst programming practice since dos era!

2 stars Unclear and a general disappointment

1998-08-10     5 of 16 found this review helpful

I found this book to be poorly written and a general disappointment. The entire book could have (and should have) been condensed to about 20 pages. I have yet to find it helpful vs. the reg. expression cheat sheet that comes with any Perl book.

4 stars Deep study of a deep subject

2006-06-29     4 of 5 found this review helpful

Regular Expressions are a powerful pattern matching process built into many programming languages (but often hidden and not fully exploited).

If you are verifying input from a form or analyzing an HTML page or engaged in any other sort of pattern matching, Regular Expressions are something you should master.

The problems addressed by this book are (a) regex is poorly documented in general and (b) it has grown up ad hoc: every language's implementation is different from every other, sometimes very different.

The book does a good job of documentation and explanation in the early chapters. But in the later chapters it falls prey to the problem it is trying to solve. If you use Perl or Java or VB.NET, then this book gives a lot of very important information not easily found elsewhere.

On the other hand, if you use PHP, MySQL or JavaScript (as I do) you have to look elsewhere for the advanced topics.

5 stars Get this book and get over your fear

2004-04-15     4 of 4 found this review helpful

Regular expressions always terrified me. I really got tired of looking for related examples on the 'net and hacking sample code so I decided I had to take the plunge.

I can say that the first chapter of this book is one of the most important chapters of any book I ever read. It leaves you breathless. Actually you'll probably want to read it again as the first time round you were so glued to the pages you didn't have time to try out the examples yourself.

In a book such as this layout and typographical conventions are of utmost importance and this book gets this spot on. An author who can cover this subject without simply using masses of examples and dry outlines of selected syntax arrangements deserves an acolade. This book goes further. It stimulates the juices and is a struggle to put down (to the detriment of your hands-on practice as mentioned above).

I was quite wary of exploring the territory of regular expressions and used to be very ambivalent towards Perl but this book helped to ease me in to a whole new world of script programming.

This book is not just for Perl geeks. PCREs (Perl Compatible Regular Expressions) are creeping into other programming and scripting languages now and this book will serve you no matter where you're coming from.

Get this book and get over your fear!

3 stars can be much shorter

2001-07-11     4 of 15 found this review helpful

This book can be much shorter. There are too many unrelated and meaningless things in this book. I can learn from this book, but not effective enough.

3 stars not enough examples

2000-04-10     4 of 6 found this review helpful

A good general book on Reg Ex, but the basic problem is that its too broad. Since so many regular expression engines can be different it doesnt really spend enough time on any one to let you 'master' them.

But its still a worthwhile read, and its a good companion for Programming Perl for the perl programmers.

5 stars This is a GREAT book

2000-02-16     4 of 5 found this review helpful

This is one of the best books I have read in a long time! It is packed and dense with information (plan on reading it at least twice). The examples are wonderful. This should be required reading for any serious Perl programmer (and very useful to programmers in other languages). Not only will this book teach you to be a regex expert, but it will teach you a lot of other stuff about Perl.

5 stars The Zen of Regex

2000-01-24     4 of 6 found this review helpful

This is the best computer book I've read. It has helped me understand PERL, but it's more than that... Regular Expressions deserve to be studied in their own right, as a stimulating mental exercise... even as a form of meditation (maybe that's going a bit too far). Euclid for the new millennium.

5 stars Great book, but little Ruby

2008-09-07     3 of 3 found this review helpful

This book is great if you want to learn about what you can do with regex, how they work, how you can improve them (efficiency & accuracy) and what kind of pitfalls there are.

My only gripe is about the Ruby reference on the cover. In the top right corner it says: "For Perl, PHP, Java, .NET, Ruby and more!" Perl, Java, .NET and PHP each get their own chapters (together 200 pages). Ruby, however, only participates in feature comparisons and benchmarks. If I had checked the ToC I would've known this, so I won't hold it against the book that much.

The Ruby thing is a bummer, but since the book is great, it will get all five stars.

3 stars Will take you a long way down the rabbit hole

2008-02-15     3 of 6 found this review helpful

How deep down the rabbit hole do you really NEED to go? I had a serious need to get on top of regular expressions to solve one particular problem. I looked at several online tutorials which didn't take me where I needed to go, so I ordered Mastering Regular Expressions after reading the Amazon reviews. I always look at the negative reviews first. In spite of the negative reviews I ordered the book with an open mind.
When the book arrived I began reading it with enthusiasm. In the preface there is a small section on "How to Read This Book". I bought into the author's suggestion to read the book's first six chapters first. I was captivated through the first three chapters, and then somewhere in chapter 4 I began to get very weary with information overload. After putting the book down for a couple of days I decided to skip the rest and use what I needed to write the one regular expression I had need of. The book did successfully help me accomplish this, so I gave it 3 stars. Not only did it give me the information I needed that the online tutorials didn't, it also gave me the confidence I needed. For that, which I am grateful, I would have liked to have given it more stars. I think many of those in need of learning about regular expression could be well served by a "lite-edition" of this book. Perhaps someday when I have the time and the need I may try to wade through the rest of the book, but as it is now Mastering Regular Expressions took me far farther down the rabbit hole than I really needed or wanted to go.
If you need to get on top of Regular Expressions, I would recommend this book, however just be ready to be taken far deeper than the average coder probably needs to go.

4 stars What everyone else said...

2007-03-22     3 of 3 found this review helpful

What more can I say besides what everyone else has said.
This is a WONDERFUL and POWERFUL book on Regular Expressions.

From just-beyond-beginner to advanced, this book provides a fantastic view into the world of Regular Expressions and the practical thinking involved with them. However, without at least a semi-understanding of the concepts you will not be able to get through the book very quickly.

I walked away with MUCH more knowledge than I had expected to. This applies to not only regular expressions, but also to rational thinking/planning when it comes to data and programmatic analysis.

5 stars Excellent Resource

2007-02-04     3 of 4 found this review helpful

Regular Expressions need to be fully mastered in order to truly gain access to the power of many languages and programs. Whether you are working with Perl, PHP, Java, .NET, Ruby, C, Python or any of a variety of other languages the use of regular expressions allows you to work with your data in powerful ways. As a general rule most books that even mention regular expressions just mention a very few of the common ways to build an expression. This book takes the reader well beyond that level and explores the many more unusual ways regular expressions can be used. If you don't know what a regular expression is then you have no need for this book, but if you have ever worked with regular expressions then you are in for a treat with this book. I have used them for years and built a whole spam filter system around regular expressions but there is so much more they can do and this book can make you an expert.

After a basic introduction covering the most common tasks regular expressions are used for (substitution, selection, wild cards, etc.) the author delves into examples of regular expressions in Perl, and follows that with a section discussing some of the variations in regular expressions as implemented in different languages and common programs. One of the most important features of the book is the plethora of real world programming examples. Mastering Regular Expressions is highly recommended to anyone who wants to completely master the full art of regular expressions.

5 stars A gem - technical presentation as it should be

2007-02-03     3 of 3 found this review helpful

Regular expressions are not really for the person playing at would-be programmer. It is to the text processing person what a top-of-the-line drill is to a carpenter. It requires a dedication to detail, an ability to write out exactly what needs to be done and why it works. Regexs are used in a context. Perl for example, helps the process along by supplying a well-packaged and documented environment for regex. But this means you have to learn Perl, or Java, or PHP, Python, Ruby, whatever. This book is for the kind of person that fits somewhere in the above described mix. It is however, THE book to have when you do care enough. It is not an easy book for a beginner or those in a hurry. Whatever it is that is covered here is done well and authoritatively (spelling ?). The author knows his stuff and the pains-taking effort he talks about in his Preface is obvious to the student of the book.
I believe this topic lends itself to being best taught by looking hard at a big bunch of non-trivial examples, with a lot of surrounding comments. They are in the book, I wish there were more. Perhaps the buyers of this book, along with the regex gurus out there could start posting well-crafted regexs to some well-known spot. I believe that O'Reiily, the publisher of this boo already might have such a posting site.
Kudos to O'Reilly and to the author for a wonderful contribution to the computer programmer/science community

5 stars A Black-Art Demystified!

2006-11-18     3 of 3 found this review helpful

I don't know about you, but in over 20 years of Unix use and work, I've always had a "problem" with regex. Yes, regular expressions are ANYTHING but "regular!" ...except that the notion extends to parsing text for patterns that are common.

Using regular expressions has always been a hurdle for me. I mean, you HAVE to be able to manage them at least a little in order to be proficient with Unix, but Mastering them, that's another story entirely. Jeff's (if I may call him Jeff) book is stellar. It reads easily and provides meaningful topics on using regex to your advantage.

I can't say enough about how well put-together this book is for the average person. Every topic is clearly visited and the discussion is pleasantly light and, at the same time, technically concise so as to provide real, useful help to using regular expressions. Here is an example:

"Mimicking atomic grouping with positive lookahead"

I consider this book to be a "brain dump" by perhaps the most accomplished regex guy in the industry. In the best of O'Reilly traditions, the book is very well laid out and presented. The quality of editing and "fit-n-finish" of the book are representative of this 3rd Edition.

If you encounter Regular Expressions in your work or as a hobbyist, this book shines a light into the darkness that opens the world of regex to you. It has been very practical and useful for me and it has really helped me be a much better regexer!

5 stars Good guide to regular expressions in all kinds of situations

2006-11-08     3 of 4 found this review helpful

This book is about a very powerful programming tool. Most documentation that mentions regular expressions doesn't even begin to hint at their power, but this book is about mastering regular expressions. Regular expressions are available in many types of tools such as editors, word processors, system tools, and database engines, but their power is most fully exposed when available as part of a programming language. Examples include Java, Visual Basic, Perl, VBScript, JavaScript, sed, and awk. Regular expressions are the very heart of many programs written in some of these languages.

This book will interest anyone who has an opportunity to use regular expressions. If you don't yet understand the power that regular expressions can provide, you should benefit greatly as a whole new world is opened up to you. This book should expand your understanding, even if you consider yourself an accomplished regular expression expert. Programmers working on text-related tasks, such as web programming, will find a gold mine of detail, hints, tips, and understanding that can be put to immediate use. I've not found this level of detail and thoroughness in any other book.

Regular expressions are an idea that is implemented in various ways by various utilities. If you master the general concept of regular expressions, you'll find it easier to use a particular implementation. This book concentrates on that idea, so most of the knowledge presented here transcends the utilities and languages used to present the examples. You'll probably get the most out of this book by reading the first six chapters in sequence. The last four chapters cover regular expression specifics of Perl, Java, .NET, and PHP, and here is where you can skip around based on your need.

Chapter 1, Introduction to Regular Expressions, is geared toward the complete novice. It introduces the concept of regular expressions using the widely available program egrep, and offers the author's perspective on how to think regular expressions, instilling a solid foundation for the advanced concepts presented in later chapters. Even readers with prior experience would do well to skim this first chapter.

Chapter 2, Extended Introductory Examples, looks at real text processing in a programming language that has regular expression support. The additional examples provide a basis for the detailed discussions of later chapters, and show additional important thought processes behind crafting advanced regular expressions. To provide a feel for how to "speak in regular expressions," this chapter takes a problem requiring an advanced solution and shows ways to solve it using two unrelated regular-expression-wielding tools.

Chapter 3, Overview of Regular Expression Features and Flavors, provides an overview of the wide range of regular expressions commonly found in tools today. Due to their turbulent history, current commonly-used regular expression flavors can differ greatly. This chapter also takes a look at a bit of the history and evolution of regular expressions and the programs that use them. The end of this chapter also contains a guide to the advanced chapters. This guide is your road map to getting the most out of the advanced material that follows

Chapter 4, The Mechanics of Expression Processing, ratchets up the pace several notches and begins the central core of this book. It looks at the important inner workings of how regular expression engines really work from a practical point of view. Understanding the details of how regular expressions are handled goes a very long way toward allowing you to master them. The next chapter puts that knowledge to high-level, practical use. Common but complex problems are explored in detail, all with the aim of expanding and deepening your regular expression experience. Chapter 6 looks at the real-life efficiency ramifications of the regular expressions available to most programming languages. This chapter puts information detailed in Chapters 4 and 5 to use for exploiting an engine's strengths and stepping around its weaknesses.

Chapter 7 closely examines regular expressions in Perl, arguably the most popular regular expression-laden programming language in use today. It has only four operators related to regular expressions, but their myriad of options and special situations provides an extremely rich set of programming options and pitfalls. The very richness that allows the programmer to move quickly from concept to program can be a minefield for the uninitiated. This detailed chapter clears a path.

Chapter 8, on regular expressions in Java, looks in detail at the java.util.regex regular expression package, a standard part of the language since Java 1.4. The chapter's primary focus is on Java 1.5, but differences in both Java 1.4.2 and Java 1.6 are noted. Chapter 9 contains the documentation for the .NET regular expression library that Microsoft neglected to provide. This chapter provides the details you need to employ .NET regular-expressions to the fullest regardless of what base language you're working in. Chapter 10 provides a short introduction to the multiple regex engines embedded within PHP, followed by a detailed look at the flavor and API of its regex suite, powered under the hood by the PCRE regex library.

Overall, this is a very complete guide to regular expressions with plenty of examples and I highly recommend it.

5 stars Wow!

2004-11-30     3 of 3 found this review helpful

This is one of the few O'Reilly books that I read cover to cover. What? A book on regular expressions read cover to cover? If you have read the book, I suspect that you understand. If not, read it. Even a cursory skimming (if possible) will provide valuable information in HOW regular expressions work - the syntax, the underlying engine, differences in implementation. Highly recommended.

On a sidenote, the regular expression in the back of the book (a full page long) has been the topic of conversation in my workplace more than once. I suspect that it will eventually become one of those "geek indicators" like the number 42 or PARC.

5 stars Invaluable Regex Insights

2003-12-14     3 of 3 found this review helpful

I used, but never truly understood, regular expressions until I read this book. If you use regular expressions in a production setting you need to understand them at a deep level to make sure you won't fall into performance traps. This book provides that deep perspective. The author really knows his stuff and is able to communicate it effectively. Another O'Reilly classic.

4 stars Inspirational, but...

2003-05-10     3 of 7 found this review helpful

A good book, but it doesn't really end up offering that much. If you are good with regular expressions and understand them, this just gives a lot of more detailed, specific and complex one's. That's not a bad thing, but it's not really something you'd have any reason to use and could be done just as accurately and efficiently with a lot less code. Some of them look impressive, but are just a lot of unneeded code for the sake of looking inpressive. A lot can be had from this book, I just already know regular expressions very well, but it's still inspiring.

5 stars Excellent book on for all programming language

2001-10-01     3 of 4 found this review helpful

This book is useful for everybody who deals with string manipulation.Now even javaecript has the capability of doing so.Java has third party libraries for the same.Book incoporates examples form perl,shell,awk etc.
Must read for all developers.

5 stars Excellent!

2000-12-20     3 of 3 found this review helpful

I fought with Reg Expressions. Bash, Perl. I read this book. (Which still kicked my tail initially) By the time I actually 'understood' the last page, Everything else I was doing in Bash, and Perl just made sense. Suddenly stuff that took me weeks to do, I can do in a few minutes. Now I am working through 'Learning Perl' but understanding everything I read, because of the great foundation this book laid for me.

4 stars This book is about 'Mastery,' not 'solving your problem right away'.

2009-05-18     2 of 2 found this review helpful

Indispensable.

Friedl's 'Regular Expressions' is in-depth and thorough. It has provided me with the framework to become proficient in crafting efficient Regular Expressions as I need them, and that's just what the author intended.

It's not a cookbook to solve the problem you suspect might best be tackled with a 'regexp' expression (you know; the problem that made you think of looking at this book in the first place). But a perusal over a few nights -- not more than a week, though -- and you'll be able to work quickly and efficiently in whatever regexp-supporting environment you're in.

I never give more than four stars because nothing is ever perfect, but I'd be hard-pressed to imagine a better reference or learning aid than this book.

5 stars Good Book

2009-04-21     2 of 2 found this review helpful

As with any review of a technical book, an understanding of the reviewer's previous experience with the topic is necessary. I had understanding of regular expressions on a basic level; I knew that .* matched everything, and a few other simple expressions. This book by O'Reilly starts on this basic level, and quickly advances towards more complicated expressions. All along, it uses numerous examples to not only illustrate the usefulness of each different tool, but also the pitfalls that each tool presents. Mastering Regular Expressions clears up common misconceptions and misguided thoughts with questions of ambiguous expressions, and in doing so allows you to craft regexes without running into constant roadblocks.

After going over the more semantic expressions, the book delves into a discussion of the underlying engines that drive regular expressions in a thorough and mostly clear way, which is an accomplishment considering the advanced language theory and esoteric formulas that are the basis behind regular expressions. While Friedl's explanations and examples are top notch, I believe that his strongest point is the pace at which he goes along. Whenever I was confused or questioning why something was a certain way, Friedl inevitably encouraged a reread of the previous section. He is distinctly aware of his readership and the subject he writes about, and is thus able to know exactly when the reader should go back over a section to make sure that they fully comprehend it. Freidl shows a clear mastery of regular expressions himself, and is able to highlight pros and cons of various methods and engines, what works and what does not. This thorough understanding of the subject combined with ability to succinctly and clearly teach it makes this book a must read for anyone interested in using regular expressions in any capacity.

5 stars Incredible book

2008-02-05     2 of 2 found this review helpful

An incredible book. Absolutely incredible. It will take 200 lines of your code and reduce it to 1 or 2 lines. It will open your mind to search and replace possibilities. Your life will change (just kidding). It's a great deep book.

However, I agree with the comment that one should not begin learning regex with this book. it's a little too advanced. Go on the internet, get an introduction. Or else, buy one of the introductory books on the subject first. But definitely get around to buying this book!

5 stars Compelling read... (Did I just say that about a tech book?)

2007-12-04     2 of 2 found this review helpful

This book is seriously worth the money. I knew just enough regular expressions to get by, then I started reading this book and it has paid off already; saving me time on several long, arduous tasks.

The book is really well written, very interactive w/ quick, quizzing questions mixed throughout the chapters. The authors writing style is very effective and surprisingly entertaining.

If you don't know much about regular expressions or even if you think you do, purchase this book. It will be well worth it.

5 stars More than expected.

2007-08-23     2 of 2 found this review helpful

I have been in computer software developer over 7 years now and never really used regular expression until a year ago. True, you can live without it. But, with regular expression at hand, you climb up another level of programming. Code will be much concise and code research will be like a breeze.

Anyway, I didn't read this book entirely since later chapters explain intricacies and subtle differences of each specific language, e.g., java, perl, php, etc. It didn't take long to apply the knowledge I gained to real work and benefit. By the time I completed the first chapter, I already started to get rewards. My life is a lot easier now.

Even with only the first 3 chapters, this book is well worth its price. The author did superb job explaining what's going on behind the scene and guide you through the right way of constructing regular expressions for various situations. Of course, he will show you common pitfalls to avoid, too. Very detailed and comprehensive.

Highly recommended.

5 stars From Novice to Expert in a couple of weeks

2006-12-29     2 of 2 found this review helpful

Incredibly well written and thought out, Mastering Regular Expressions explains both the syntax and philosophy behind regular expressions. You'll find that it is throughly researched, every nuance of a given regex implementation of the four featured languages (Perl, Java, ASP and PHP) is covered in extraordinary detail, containing information available NO WHERE online.

I bought this book after tooling around with regular expressions for a year or so and having limited success, my training having been limited to short online tutorials. After reading Friedl's guide, I have become much better at CORRECTLY programming regular expressions and "thinking regular expressions", that is, changing my outlook on a given task in order to apply regular expressions. I would highly recommend this book to anyone who deals with textual data on a daily basis, including, programmers, web developers and writers of any type.

5 stars Thorough Regex book

2006-08-23     2 of 3 found this review helpful

This book is an invaluable resource. I learned more than I wanted to know about regex after reading this book. The authors breaks things down to the smallest detail and discusses each aspect. He covers regular expressions, their engines, their use, and some tips and tricks without losing the reader.

If you are just learning regex, I don't recommend this book - but if you know a little and want to take your regex to the next step, this is the book for you!

4 stars A detailed view of the inner working of regular expressions

2005-06-05     2 of 2 found this review helpful

How come a technology that is as old as computers themselves is still around? Regular expressions solve one of the most basic problems in computer science: parsing strings.
There is no doubt that regular expressions are beasts. This will will demystify them. By understanding them, you will be less scared of using them. This book does just that. However, the level of this book is high and the level of details amazing. It is not a cook book so it would be wise to also read another book that gives you more examples. This particular book is like the bible of regex. It needs to be in your library.

5 stars 10 STARS

2004-09-09     2 of 2 found this review helpful

If I could give this book 10 stars I would.

This book opened my eyes to a lot of possibilities with regular expressions that I never knew existed. I had heard of regex programming for years, but had no idea they could be so powerful.

I don't know what else to say that hasn't already been said in other reviews. If you want or need to learn regular expressions, this is the *only* book you will need to buy.

4 stars HIGHLY INFORMATIVE

2003-01-31     2 of 3 found this review helpful

At roughly 500 pages, this book can hardly be described as voluminous. Yet; the details it apportioned to each of its chapters is great. It comprehensively dissected all those qualities that made Regular Expressions so important.
In fact, any computer language beginner who wants to learn about Perl, Java, or any of those languages that use the .NET Framework should, (first of all), consider building a solid Regular Expressions foundation with this book. It is highly informative: especially if you are inclined to Perl.
Proper use of this book ensures that one does not get confused, as regards the many options that Regular Expressions provide for any given problem. It has a great value!

5 stars regex bible

2001-09-26     2 of 3 found this review helpful

To my knowledge, this is THE authoritive book on regular expressions.

I use the book mostly as a reference (usually when writing perl code), although it's history of different regex engines and their differences is quite interesting as well.

5 stars Greatest computer book I've ever read

2001-08-23     2 of 2 found this review helpful

This book is written in an easy-to-read conversational style, which makes it a joy to read through and easy to absorb all the wonderful content presented. I've read everything but the appendix and Chapter 7 (as I'm not a perl programmer, yet), and, if you start at chapter 1 and keep reading, it slowly explains regex's from start to finish. It begins with an introduction to regex's, and moves on from there, getting deep into how the regex engine parses your regular expression and how to take advantage of that knowledge to optimize your expression, and how the differences between programs' regex implementations affect your use of them. And all this is presented in a manner that is easy to absorb. Truly a gem in technical books!!!

5 stars PHP User says "thumbs-up"

2000-10-01     2 of 9 found this review helpful

Although not written exclusively for PHP users, I bought this book for use with PHP. Sometimes the Perl-skewed text can be a little overbearing, but I think that will be useful in the future.

Anyone who's into GNU type programming will benefit greatly from this book. Get it, use it... build better programs.

5 stars Excellent read for the beginning programmer

2000-05-04     2 of 3 found this review helpful

There's just a world of power at any user's fingertips, and it's regular expressions. For any task that involves anything with alphanumeric characters, there are few, if any, ways to manage large chunks of them more effectively. Regular expressions harnessed to Perl are the tools that you need to do essentially anything on your computer. This book is like a scuba diving lesson for any reasonably competent computer user: it will take you to fascinating places you haven't been, it will make you think and be a little uncomfortable at first, but it will incredibly exhilarating when you're actually doing it.

5 stars Serious regular expression magic for the hard-core hacker

2000-04-14     2 of 2 found this review helpful

This book was written with a thoroughness that is only possible when the author loves his subject.

As a long-time UNIX hacker, I thought I knew regular expressions. I mainly bought the book to gain a fuller understanding of the intricacies of Perl regular expressions. I learned that, when it came to REs, I was a rank amateur. Jeffrey Friedl is the master. The Perl chapter alone is worth the price of the book....

4 stars Language description..

2000-02-26     2 of 3 found this review helpful

Regular expressions look nothing but regular, more often than not because of the idiosyncratic tool being employed. This book surveys the notation, presents techniques and gory details about the languages which support this notation.

I was a casual user(mostly in scripts) before, but now have become more careful in regex construction.

I found it a tad verbose, but I heartily recommend it for any programmer.

5 stars Click the Button - Buy this Book!

1999-12-16     2 of 3 found this review helpful

This is easily one of my most-used books. O'Reilly book are generally of the highest caliber, but this one ranks amongst the best of the best. It clearly handles the current state of regular expressions, something that many of my university classes haven't (they're still stuck in the morass of "pure" regexes). While the book is somewhat Perl centric, a host of other languages are addressed. If regular expressions have you baffled, or if you need to craft just the right regex for your application, this book is for you.

5 stars Masterful. Thoughtful. Brilliant.

1999-10-09     2 of 2 found this review helpful

One of the finest technical books I have read (out of hundreds). He has an extraordinary knowledge of Regular Expressions, and he has written a beautifully crafted book explaining the concepts. A true master craftsman, both in his understanding and his ability to explain. I look forward to more work from this excellent author.

5 stars Mastering Regular Expressions is essential reading for anyone in IT

2009-12-31     1 of 1 found this review helpful

I've been using regular expressions (knowingly / intentionally) for the better part of the last 2 decades, and yet until I read this book, I didn't fully realise what a powerful set of tools I had at my disposal. Jeffrey Friedl's explanation of what makes the various types of engines work, and the chapter on optimising regexes for NFAs were extremely helpful. As a network security administrator I find myself having to parse through massive amounts of text and data a regular basis, and thanks to this book, I've been able to better automate a lot these processes and gleam more valuable data from the waves of information waiting to be processed. This book really should be essential reading not just for programmers and web developers, but any one who works in IT or might benefit from the use any kind of scripting / automation.

4 stars take the fear out of regex

2009-05-27     1 of 1 found this review helpful

Very useful book, the first 6 chapters are general introduction to the tips and tricks of creating and using regexes which applies to all flavors and versions of regular expressions in different programming and scripting languages. The author has a good writing style which does not intimidate but is to the point and concise.

5 stars VERY VERY HIGHLY RECOMMENDED!!

2007-05-23     1 of 1 found this review helpful

Are you a programmer working on text-related tasks? If you are, then this book is for you. Author Jeffrey Friedl, has done an outstanding job of writing a cool book that will interest anyone who has an opportunity to use regular expressions.

Friedl, begin with an introduction to the concept of regular expressions. Then, the author takes a look at text processing with regular expressions. Next, the author provides an overview of features and utilities, plus a bit of history. He also explains the details of how regular expressions work. The author continues by working through regular expressions examples. Then, he discusses efficiency in detail. Next, the author covers Perl regular expressions in detail. He then looks at Sun's java.util.regex package. The author continues by looking at .NET's language-neutral regular-expression package. Finally, the author looks at PHP's preg suite of regex functions.

This most excellent book should expand your understanding, even if you consider yourself an accomplished regular-expression expert. Perhaps more importantly, the book concentrates on mastering a particular implementation!

4 stars Good Information

2007-05-07     1 of 1 found this review helpful

Many people only barely utilize regular experssions, having been unable to get more than basic expressions to work. There are a lot of reasons for this - shell escapes, man pages that are terse to the point of being cryptic, etc. This book is a clear and very readable trip through practical regular expression creation and application that will enable the reader to get the most out of grep, awk, perl and other programs that use regular expressions.

5 stars The ultimate book for the ultimate demands - For an introduction just too heavy weight

2007-05-03     1 of 1 found this review helpful

Jeffrey Friedl describes regular expressions at an amazing depth and precision. Regular expressions are not easy and the quirks of the different tools (including their exact version and for what operating system) make writing them to an irritating black art. A black art to almost anybody. MRE sorts everything out in a comprehensible fashion. The price the reader has to pay: a very dense book, a need to follow the details until your head starts swimming and a lot of strain on the memory about what works, how and where.


MRE is somewhat easier to comprehend for a reader with a strong Pearl background. Also a good prior understanding to regular expressions is a true asset here. If you have neither, you do not need to despair. Jeffrey Friedl explains everything thoroughly from the ground up.


The writing style is very pedagogical. Important things get repeated quite often. Still this book is very dense. The flow is dry: no rhythm, special sense of humor or wit sweetens your wading through the material. Nevertheless Jeffrey Friedl kept my interest through the pages though the reading felt like hard work.

I do recommend this book to the truly dedicated reader.

5 stars Such a good resource on Regex.

2005-04-27     1 of 1 found this review helpful

If you are an experienced programmer, then you have undoubtedly heard of the power behind regular expressions. Unfortunately, even for seasoned developers, becoming very proficient in regular expressions is no trivial task... or is it? Sure most regular expressions look very arcane and are even harder to write, but luckily there is at least one good resource to help bend the learning curve. I am talking about Mastering Regular Expressions by Jeffrey Friedl. This book breaks down regex to such a trivial level that you can't help but learn how to harness the regex power. Jeff takes you step by step through regex land and holds your hand throughout the whole trip. Next thing you know, you will be crafting high quality regular expressions and you will learn how to truly harness such a powerful tool.

Unfortunately in every programmers life there are mental blocks that keep us from truly progressing. For some it's pointers or OOP concepts and for others such as myself its regular expressions. This book took that mental block and smashed it, then it paved the way to regex land. Now I feel much better! HIGHLY recommended!

5 stars Very worthwhile book

2004-12-20     1 of 1 found this review helpful

I found this book to be really useful. It was an easy to follow step by step descriptioon of the regular expression language. It also provided valuable insight into the regular expression evaluation engine which is critical to creating efficient and performant expressions.

A must read for anybody that wants to really write effective regular expressions.

5 stars Ding ding ding - we have a winner

2004-10-07     1 of 1 found this review helpful

Great book for newbies and advanced users alike. Regular Expressions are a pain to understand and learn, but this book is a great teaching tool for that. If you're interested in learning RE, this is the book to start with.

5 stars Good geek book

2004-09-30     1 of 1 found this review helpful

Mastering Regular Expressions is for many people including among others casual users, system administrators, and programmers. Only programmers will understand (or need) the whole book, but people with only a tiny little Perl or Unix knowledge will gain much from the first few chapters. The RegEx book is useful as a primer to go a little beyond the usual wild card (i.e. '*') when searching text files for something, it's useful for systems administrators who need to write task automation scripts, and it offers Perl, Java, and .NET programmers a complete reference to the RegEx engines they need to understand to optimize their code.

And if they don't already have it, this will make a great present for your techno geek other half. They'll be impressed...

5 stars Excellent Learning Tool

2003-11-20     1 of 1 found this review helpful

I have struggled with regular expressions for a couple of years now. Like most people, I knew 'something about them', and could cobble together a simple regex. But when it came to more demanding searches, I had to find the regex on the web, or I was out of luck.

This book guided me to the next level (at least). It is one of the better computer tutorials I have read in the past couple of years. If you are looking for a resource to learn regular expressions, this is the one I'd recommend.

4 stars Need to get to speed quickly? This is a good start...

2003-07-12     1 of 1 found this review helpful

While the various websites give a lot of good information on regular expressions, they don't show enough about building them from scratch. This book does a great job of laying a good foundation and then helping the reader understand how to build expressions from there.

5 stars Great book to learn about Regular Expressions.

2003-07-02     1 of 2 found this review helpful

If you want to learn the ins and outs of how a regular expression really works, this book does a great job explaining all the syntax, intricacies, optimization, greedy match, and non-greedy match. I highly recommended for those who writes a lot of regular expression.

5 stars Friedl once again wrote the ultimate book on the subject

2003-05-14     1 of 1 found this review helpful

Regular Expressions are a powerful tool, but not a topic that easily lend itself to a light reading. Notwithstanding the author's very informal writing style and genuine enthusiasm, a few sections can be dry or even cryptic (especially for beginners). Anyway, Friedl once again wrote the ultimate book on the subject, with an intimate knowledge of Regular Expressions, an outstanding attention to every detail and a huge amount of useful and relevant examples. Compared to the previous edition it covers new features but also expand on a broader range of programming languages, with dedicated chapters for Perl, Java and .NET; PHP, Phyton and Ruby get some coverage as well

5 stars If anything like the 1st Edition...

2002-08-24     1 of 4 found this review helpful

Regular Expressions is not intuitive, but they sure solve a lot of ugly text-related problems. Mastering Regular Expressions will teach you the required how to's & pitfall's.

Previous reviewers are right, there's a lot here, but since when is throughness a crime?

5 stars regular expressions are very useful

2001-12-01     1 of 1 found this review helpful

I have been getting into regular expressions, as I realized, how powerful and useful they are, I started to use more advanced features, and started to run into topics that weren't fully documented in the python or .NET documentation. I guess, I never looked at Perl documentation. Though this book turned out to be a real gem. Each time so far that I needed some help with regex, the book showed it to me quickly and easy to understand. Plus, O'Reilly books really rock. I'm going through a lot of technical books. And, by now O'Reilly convinced me that they have a good quality control.

4 stars Not a book for easy answers and examples

2000-03-09     1 of 2 found this review helpful

A friend let me borrow this book while I was writing a Perl program to capture system statistics. I was hoping to have something with easy explanations and lots of examples, which this book does not provide. Buy it if you want to _MASTER_ REs, but look elsewhere if you need an intro first. Please note that I revised my rating to 4/5 because I admit that I expected the book to be something it wasn't intended to be, but with so few (if any?) intro books about REs on the market, I still think the author missed a chance to explain REs to newcomers.

4 stars Wordily book

1999-08-31     1 of 2 found this review helpful

The author talks so much of unrelated stuff outside regular expresions. However he gives good examples and cases for the use of regex.

5 stars Excellent Apporach to Writing Regex!

1999-02-03     1 of 1 found this review helpful

This book is quite possibly the most important book I have read about the philosophical approach to programming regex. Not just for those wanting to program Perl.

5 stars This book is for programmers with insomnia!

1998-06-12     1 of 3 found this review helpful

Wow. After reading O'Reilly's first book on the Perl language in general, this book was the real eye opener to realizing that Perl was truly a powerful language. The examples provided in this book are real world examples you can take and use or modify within your own code. If you look above, I rated this book at five stars; but then you might wonder why I said this book was for insomniacs?! Everytime I try and sit down to read a few chapters I end up feeling sleepy and nodding off! One of the most noticeable chapters in the book is the discussion on DFA versus NFA implementations of various regular expression parsers: Perl, Python, Tcl, POSIX, grep, emacs... If you want to truly optimize your code, this is the chapter to read to analyze all your "hot spots." Later chapters deal with even more real world applications, such as IP addresses and WWW pages. Don't let those big nasty regular expressions scare you though. Pretty soon you'll be able to read and understand powerful expressions that will let you manipulate any kind of text you come across.

5 stars And you *thought* you were a regular expression guru, eh?

1997-05-13     1 of 2 found this review helpful

Prepare to be humbled! Jeffrey Friedl will show you just how little you knew about regex's...even when you thought you knew it all. What may initially appear to be a dry subject becomes absolutely fascinating with his sometimes humorous (but always accurate) writing style. Learn the dangers of: ``([^"\\)+)*'' and more! Beyond the topic of regular expressions, this book engages the reader in the general processes of thinking and analysis

5 stars Bravo!! I have 20 OReilly Books, and this is the BEST!

1997-02-16     1 of 2 found this review helpful

After reading just 50 pages, I stopped and went back to look at some of my old awk code. I turned 32 lines of code into 3. I spend so much more time on the computer, my wife wants to sue the author for "causing a divorce"! She can't wait for me to finish the book. I have always wanted to know more about regular expressions, and you have shown me the light. If you are a manager of a technical staff (like myself) and you want to stimulate creativity. buy this book for them. I have heard more "did you know you can do this" statments while passing workstations than I ever have. Awesome! We all would like to thank Jeffery Friedl and OReilly and Associates so much.

4 stars Nice comprehensive overview

2009-08-22     0 of 0 found this review helpful

A nice look into the mechanics of regular expressions, starting from a birds eye view and diving down into the details.

5 stars The Regex Book

2009-08-14     0 of 0 found this review helpful

This book covers regular expressions thoroughly and completely. It covers them in a way that is easy to understand and yet guides you through the complexity of this powerful tool. If you only buy one book on regular expressions, this is it. Easily one of the best technical books I have read.

5 stars \bGreat\sBo{2}k\b

2009-05-21     0 of 0 found this review helpful

This is the standard textbook on Regular Expressions and for good reason. The third edition however covers the different shades of RegEx from many programming perspectives including {Egrep, Perl, PHP, Java, .NET}

A mix of humor coupled with real examples will get you to master status with RegEx in no time. I have read this book like 5 times and still use it a lot.

This book does for RegEx what Cormen's book does for Algorithms.




5 stars Excellent Book

2009-04-18     0 of 1 found this review helpful

If you have decided to achieve the thorough knowledge of regular expressions, your search ends here. Get this book and read it. Believe me you don't need to take any course or pay high fees to extensions to learn RE.

I strongly recommend this book.

-Mohammad K.

5 stars Now I really know regular expressions!

2009-02-20     0 of 0 found this review helpful

Simply put, this is the most useful book I have ever read in my 28 years as an engineer and computer programmer. Highly recommended.

5 stars The Only Book You Will Need

2008-12-12     0 of 0 found this review helpful

This book is fantastic. Given the complex nature of regular expressions, the author explains the material in an easy-to-understand and clear manner. The read was never dry or boring, like might be expected with such a topic. It covers the topic completely - you will not need to buy another book to learn more. This is THE book to get if you want to learn regular expressions.

I have read many computer books, and this one ranks in the top 2!

3 stars Very good book

2008-11-21     0 of 3 found this review helpful

Das ist sehr gutes Buch und hilft mir zu verstehen, die grundlegenden "regulären Ausdrücken", dass man versuchen mit vielen verschiedenen Sprache Paradigma.

3 stars Overall good book with some quirks

2008-06-19     0 of 0 found this review helpful

The book is robust and goes into alot detail. I liked the comparing and contrasting between the various RegEx implementations. I had a difficult time digesting some of the detail. In particular, the analogies confused me and I felt the author went overboard with them. Many times, I had to backtrack to understand what was being discussed. However, regular expressions is a complex topic and the author did a good job easing into the concepts. An additional plus was with inline page citation - this helped to find the page corresponding to the topic being discussed.
I would have liked shorter chapters with chapter summaries and more diagrams in place of analogies. Ultimately, Mastering Regular Expressions is a good book referencing a complex topic.

5 stars Best material I have seen on regular expressions

2008-06-01     0 of 0 found this review helpful

I went through several books and online tutorials and never found anything that did a good comprehensive job of explaining regular expressions. This book does. If you are having trouble "getting it", I highly encourage reading this book. You will be extremely enlightened even after the first few chapters.

4 stars Very in-depth

2008-05-23     0 of 0 found this review helpful

Quite a comprehensive guide to regular expressions. Gets very detailed in the areas that it covers. However, definitely not a 'beginner's guide'. I highly recommend that you are already comfortable with the basis of regular expressions before picking up this book. You will get way more out of it if this is not your first introduction to it. Comfort and proficiency with Perl would also be a big help. Title is correct though, this is a guide to 'mastering' regular expressions, not learning them from the beginning.

5 stars Best Regex material I've ever read

2007-08-16     0 of 0 found this review helpful

Before reading this book, I would have considered myself an intermediate regexer. After the first 2 chapters, I realized how novice I really was. Having only made it through 5 chapters of this book, I can't say enough about it. The detail and step-by-step analysis that Mr. Friedl takes to describe the regex matching process is the best I've ever seen. It's little things that make the analysis easy to follow -- like the brackets he uses to mark the regex, and the small triangle cursor to show where the engine is in the matching process. I continue to look forward to each new chapter. Thank you for a wonderful work of art.

5 stars Fantastic resource, don't go without it

2007-04-26     0 of 0 found this review helpful

This is must-have if you are trying to learn regexps or improve your knowledge of them. It carefully walks you through how to construct expressions, covering everything from the most basic tasks to complicated scenarios. It explains how matching works, so you can really understand what is going on behind the scenes.

5 stars Great Book!

2007-02-21     0 of 0 found this review helpful

This is a great book for learning about regular expressions. It goes into much detail, yet still remains an easy read for a novice who has not had much experience to RegEx. Recommended.

4 stars Great reference to Regular Expressions

2007-01-18     0 of 1 found this review helpful

Regular Expressions can be confusing unless you use them everyday. This book is a great quick reference and will provide the deeper level information you need for those harder solution.

4 stars Excellent beginner book

2007-01-03     0 of 4 found this review helpful

Very nice, good explanations.
Not exactly a plain old reference type book.

5 stars Fantastic

2006-11-10     0 of 3 found this review helpful

Well written, informative, and surprisingly accessible. I have some great new tools to do my work efficiently.

5 stars The book that got helped me get my start

2005-03-31     0 of 0 found this review helpful

Jeffrey Friedl is the man whom I credit for getting my start in computer programming. I even sent him a thank you letter after reading his first edition. Once you take the time to learn Regular Expressions, you'll often wonder how you got by without them. There is no better book to teach you than this one.

5 stars Still the classic...

2005-02-24     0 of 0 found this review helpful

[Review of 3rd edition]

I last reviewed this book in early 2005 when it was still in the second edition. But with the release of Jeffrey E. F. Friedl's Mastering Regular Expressions (3rd Edition), I thought it best to give it another look. It's still great, it's still the definitive guide to the subject, and now it gives PHP'ers more to work with...

Contents: Introduction to Regular Expressions; Extended Introductory Examples; Overview of Regular Expression Features and Flavors; The Mechanics of Expression Processing; Practical Regex Techniques; Crafting an Efficient Expression; Perl; Java; .NET; PHP; Index

As with the last edition, you'll find nearly everything you need to know about regular expressions here. Since the general rules of regular expressions haven't changed much, it's not as if you're trying to learn regex version 12.5. The main difference in this edition is that Friedl gave PHP a whole lot more coverage in this update. PHP has become more mainstream over the last year or so, and if that's your area of interest you'll find more examples and guidelines now. Java 1.5 and 1.6 have also emerged since the last writing, so there's a bit more clarification as to how regex coding has changed (not much).

My initial recommendation hasn't changed one bit... If you do anything with regular expressions in your programming, get this book, put your name in it, and don't let others borrow it...

4 stars Everything you ever wanted to know about regex

2005-02-16     0 of 3 found this review helpful

Like the other Oriely books I've read, this book tells you everything you ever wanted to know about regex and probably a lot of stuff that is interesting but not practically nescary. This book covers regex egines and most common implimentation of regex. It's all good stuff but I would like a book that is more focussed on the practical details of this how you write a regex to validate a phone number or a data etc....

5 stars Another excellent O'Reilly book

2004-03-22     0 of 3 found this review helpful

This is a great guide to regular expressions in Perl. It's so nice to see a 'proper' book once in a while, instead of superficial dumbed-down crap.

5 stars Amazing book

2004-01-26     0 of 1 found this review helpful

I had just started learning perl and I knew I needed to learn how to use regular expressions. I breezed through learning perl and this book was next.

I knew very little about regular expressions before reading this book and now I feel like I've mostly mastered them. I've read through it once and there is a lot of material that it covers so it was difficult to comprehend all of it the first time through but I feel I've understood the majority of regular expressions. I think the only part I would need to read through more is the optimization of regular expressions.

5 stars Useful book

2003-11-03     0 of 0 found this review helpful

This book offered much additional information (e.g. history) about regular expressions, and will certainly be used further for reference purposes. First reading the book 'Learning Perl' from Randal Schwarz (O'Reilly) gave a headstart in understanding further the regular expression examples of e.g. Perl.

5 stars regular expressions are very useful

2001-12-01     0 of 0 found this review helpful

I have been getting into regular expressions, as I realized, how powerful and useful they are, I started to use more advanced features, and started to run into topics that weren't fully documented in the python or .NET documentation. I guess, I never looked at Perl documentation. Though this book turned out to be a real gem. Each time so far that I needed some help with regex, the book showed it to me quickly and easy to understand. Plus, O'Reilly books really rock. I'm going through a lot of technical books. And, by now O'Reilly convinced me that they have a good quality control.

3 stars Great subject - poorly written book

1999-09-20     0 of 0 found this review helpful

Not just what the book tries to say, it is how it says. In this regard, this book falls short of its promiss.

I hope the author will re-write/organize the book to make it fun to read and provide many little examples (eg. like Programming Perl, Perl Cookbook,etc..) to make it fun to read.

5 stars No BS Just pure Regex - Excellent

1999-09-18     0 of 2 found this review helpful

VERY GOOD BOOK. If u want to learn Regex Buy this no where will u find so many wonderful details about Regex and its implementation and uses.

5 stars Extraordinary

1999-07-30     0 of 0 found this review helpful

This book opened up a whole new world of computing for me. Regular expressions will save you unbelievable amounts of time. The author's explanations are wonderful. No stone is left unturned. You will never think about text the same way again.

5 stars Reading time repaid a thousandfold

1998-08-24     0 of 0 found this review helpful

For everyone programming in a UNIX environment or with tools coming from it (e.g., grep & friends).

Good read. Easily understood. Applying regular expressions saves you unbelievable amounts of time. This book has probably the best immediate earnings/cost ratio of all books I ever bought.

Buy it. The sooner the better.

5 stars The source for regular expression info

1998-08-05     0 of 0 found this review helpful

Once again, it is an O' Reilly book that stands out above the rest. This book does a great job explaining and comparing Perl, sed, awk, grep, egrep, etc. syntax for regular expressions. It is lacking on regex and regexp libraries, but in depth enough to get the idea.

5 stars Great Book for learning Regular Expressions

1998-06-18     0 of 0 found this review helpful

Great book for learning Regular expressions, the only one I think. Even great for using it in VB with things like RegularX (activeX control for Visual Basic Regular Expressions, etc). I liked it to learn how to manipulate text.

5 stars excellent for learning and reference -- indispensible.

1998-06-04     0 of 0 found this review helpful

This is #1 on the list of books I wish I'd had from the first day I began programming. It's everything you'll ever need or want to know about REs, and then some -- and very intelligibly written, too.

5 stars Bravo!

1997-11-30     0 of 0 found this review helpful

When last did you pick up a book on a dry, technical subject, and have it turn out to be a real page-turner?

Thoroughly informative, accurate, insightful, and (beleive it or not) entertaining! This is an author who knows his stuff inside out, and has an absolute mastery of the art of communication. Undoubtedly, by far, the best technical book I've ever read.

What's Mr Friedl writing next?

5 stars A shame that it was only printed on paper...

1997-11-16     0 of 0 found this review helpful

...because even the hearty bond used by O'Reilly is already dog-eared and in danger of wearing out after 5 months of use! My prior review, in retrospect, was not nearly as enthuiastic as it should have been. Even after several cover-to-cover readings, you'll still find this as a must-have reference. Prepare to use your yellow highlighter a lot to mark the gems you'll find yourself using.

5 stars this book saved my client $10,000 in a week

1997-11-05     0 of 0 found this review helpful

I had to convert a client's db-backed Web server from the Illustra Web Blade (where it was deadlocking) into the safe fast land of AOLserver Tcl. This involved writing a Perl program to parse the Web Blade syntax and then generate Tcl with the appropriate AOLserver API calls. I didn't have the BNF for the Web Blade language and didn't particularly feel like figuring it out. Reading _Mastering Regular Expressions_ enabled me to hack this out pretty painlessly in Perl in a day or two. Probably saved the client $10,000 in programmer time.

Jeffrey Friedl would say that you're supposed to read it from cover-to-cover but I think that you can benefit by pulling it out in emergencies.

Anyway, I had to pick four O'Reilly titles to give away every month from and this book was the first that came to my mind.

Why doesn't this book get a 10? Because in a world with _Anna Karenina_, I don't think any computer trade book deserves a 10! END

5 stars Looking forward to another book by Jeffrey!

1997-07-17     0 of 0 found this review helpful

I was struck by the language analogy that he gave in the introduction. It was then, that I knew, that I would end up buying this book and put an end to this reg. expr. mystery once and for all! O'Reilly has the reputation of publishing very technical, to-the-point books and authors like Jeffrey make it come true. I am really looking forward to another book on some other arcane topic by him

5 stars First time ever unable to put down a book on ... programming

1997-06-06     0 of 0 found this review helpful

Friedl's book is a masterpiece on all levels - he makes a dry subject fascinating and exciting, coaxes and encourages you through the tough parts without nannying you, repeatedly emphasises important points without boring you, scatters tempting glimpses into later topics and crafts a book which is a delight to read.

In his preface, Friedl advises readers to avoid the temptation to leap to the chapter on their favourite tool, and instead read the book first as a story. The flow of his writing makes it hard to read it any other way. The only distraction is the desire to constantly check your code against that in the book (a desire which usually leads you to completely rewrite your inefficient code).

I cannot recommend this book enough to anyone who wants to make their life easier. Must go now, as I still have 5 pages left before I get to the end

Buy it from AmazonNow