Goodreads helps you keep track of books you want to read.
Start by marking “Mastering Regular Expressions” as Want to Read:
Mastering Regular Expressions
Enlarge cover
Rate this book
Clear rating
Open Preview

Mastering Regular Expressions

4.15  ·  Rating details ·  2,005 ratings  ·  68 reviews
Regular expressions are an extremely powerful tool for manipulating text and data. They are now standard features in a wide range of languages and popular tools, including Perl, Python, Ruby, Java, VB.NET and C# (and any language using the .NET Framework), PHP, and MySQL.

If you don't use regular expressions yet, you will discover in this book a whole new world of mastery o
Paperback, Third Edition, 515 pages
Published August 18th 2006 by O'Reilly Media (first published January 8th 1997)
More Details... Edit Details

Friend Reviews

To see what your friends thought of this book, please sign up.

Reader Q&A

To ask other readers questions about Mastering Regular Expressions, please sign up.

Be the first to ask a question about Mastering Regular Expressions

Community Reviews

Showing 1-30
Average rating 4.15  · 
Rating details
 ·  2,005 ratings  ·  68 reviews

More filters
Sort order
Start your review of Mastering Regular Expressions
Aug 03, 2017 rated it it was amazing
Shelves: tech, ebook
Mwah, mwah! Thank you, Jeff Friedl, for finally - FINALLY - demystifying this most crucial of meta-programming skills: regular expressions. I had tried online tutorials, videos, even a retro bash game, this and that. Nothing ever helped. This did. FINALLY. FINALLY!

So I didn't "read" the whole book, but whatever, the second half is reference material for languages I never use nor plan to use (Perl, PHP, etc.). Honestly, the first 2-3 chapters were sufficient; once he got into the guts of differen
Jul 27, 2019 rated it liked it
Loved it. Pretty much love everything.
Jesse Houwing
Nov 09, 2013 rated it really liked it
Shelves: work
If you ever need to dive deeply into regular expressions, then this is the book to read. It doesn't just cover syntax, but dived deeply into state machines, optimizations and the way the engine's are generally implemented.

This book, however, doesn't tell you how to use each different dialect of Regex out there and some of the things the book explains might not be true for your regex engine of choice. I've used it a lot in conjunction with the Regular Expression Pocket Reference: Regular Expressi
Abhishek Kumar
Jul 24, 2017 rated it it was amazing
Giving this book a perfect rating because this enables you to think in terms of building a correct and efficient regular expression and does that with a great correctness and efficiency. Had a doubt in a section of book, emailed author and he replied promptly! It discussed in great deal the mechanism of the engine and which helps to think in terms of regular expression.
Feb 09, 2020 rated it really liked it
Really good book about regular expressions. It covers the basics and builds up to more advanced details. By the time I got to read this book I was already familiar with regular expressions and pretty comfortable using them, but this book helped me a great deal with understanding how engines actually go about.
I especially liked chapter 4. Skipped everything past Chapter 6 since they're tool-specific discussions and probably outdated. By the way, there are many dated things in this book but they a
Jean Tessier
Jun 08, 2018 rated it it was amazing  ·  review of another edition
Shelves: software
Good, practical guide for understanding how regular expressions work without going into the deep stuff about automata theory. I was hoping for more practical coverage of different syntaxes and more examples rewritten in each, especially Emacs. Still, quite good about regular expressions in general.
But if you want to learn a particular flavor, you will need something more focused on that language or tool.

There is a more recent edition published in 2002 with 150 additional pages that I haven't l
Apr 25, 2018 rated it it was amazing
Shelves: bulk_import
To be upfront, I did not read the book cover to cover - I stuck to the chapters that were relevant to me and what I needed in an immediate sense. That being said, the content in those chapters was invaluable.
Sam Klein
Jan 23, 2020 rated it it was amazing
This book gives so much. If you need a reference, this can be that book, but if you need a well-structure narrative that explains the composition of regex, look no where else. I take this wherever I go.
Joe Devon
Nov 12, 2017 rated it it was amazing
If you're a programmer of any kind you should know regular expressions. And if you want to learn regular expressions, this is the bible. That's all there is to it.
Saravanan A
Jul 20, 2018 rated it it was amazing
The best book on regular expressions
Doug Wolf
Feb 23, 2019 rated it it was amazing
This book really cleared a lot of the fog about regular expressions and the power they unlock.
Nov 25, 2019 rated it really liked it
I just read the first six chapters to solve a quiz in An Introduction To Programming In Emacs Lisp.

I still read this book everytime I need to write expressions.
Sergey Machulskis
Feb 27, 2020 rated it really liked it
Shelves: professional
The book cleared a lot of fog in my understanding of regular expressions. I knew they're based on finite automata theory (from this excellent book, which I highly recommend). I thought DFAs and NFAs are equivalent in power and different regular expression engines just implement their own translations of regexes to those NFA or DFA forms. It turned out, modern regular expressions much, much more powerful than NFAs. This book explains why. As a side effect, it helps to understand how to craft corr ...more
Rick Strong
Jul 29, 2015 rated it it was amazing  ·  review of another edition
I'm currently reading this book, not done yet, but I'll rate it 5 stars anyway for its usefulness. Regex, which provides a formal way to express text search patterns, is one of the things I always promised to learn properly, since the need for it - finding and replacing text - pops up so often in software development. In my current assignment I've had to use it on a VERY regular basis, and this prompted me to sit down with this volume and go through it front to back.

The first part of the book d
Oct 30, 2007 rated it really liked it
Shelves: development
In writing code, regular expressions are used to find patterns in text. This book explains what they are and how to use them effectively. Chances are you will find out more than you ever wanted to know about them, and quite possibly more than can be immediately assimilated. The author stays focused on regular expressions; all his extensive examples are regex-specific, there is no time wasted on introducing language basics that the reader could easily find elsewhere. The transition from easy exam ...more
Jun 29, 2009 rated it really liked it
I am reading "Mastering Regular Expressions" by Jeffrey Friedl, and am really enjoying it. Not only is it a topic that I find very interesting, but Jeffrey does a great job of leading you (and challenging you) on a path of discovering the power of regex. The narrative is sometimes a bit too self-conscious (the author never lets you forget that it's HIM doing the talking), but that can be forgiven because the book is well written and interesting.

I don't read a lot of technical, "geeky" books, so
Jun 13, 2008 rated it liked it
Shelves: programming
I read the first edition many years ago and while I don't remember the contents in detail, I get the impression that this edition has a much smoother opening than its predecessor, and is thus an easier book to read for less experienced programmers. The first few chapters teach the core techniques, with could recaps and summaries, as well as a lot of useful examples.

The second half of the book is much more advanced and focuses more on the technical aspects of regex engines, ways of maximizing ef
Jan 31, 2013 rated it it was amazing
This was my first book on Regular Expression, so I won't be saying that it is the best or most thorough (no real frame of reference), like some other reviewers do. However, I love the style, the layout, the amount of detail, ... everything about this book. I tend to read a few books on a subject I am researching, because I feel like certain things were not covered or were covered poorly. I will not be picking up another book on RegEx. I will certainly revisit this book from time to time.

I canno
Aaron M
Aug 16, 2007 rated it really liked it  ·  review of another edition
The thing about this book is that it one of those rare texts that can be read cover to cover or used as a reference. This is what we can only wish a textbook would be like.

The book is intense. For practical purposes, you should at the very least read the section covering the basics. That will give you an understanding that will cover 90% of what you might need to do in the real world. After that you can use it to look up issues as they come.
Sep 18, 2007 rated it it was amazing
Recommends it for: geeks
Heh, heh. I said "Mastering"

Regular Expressions (or RegEx) are a powerful way to recognize and define complex patterns in strings.

My 4-year-old daughter is learning math, and they're starting by teaching her to recognize patterns.

All of research is merely the recognition of patters in data.

This is a really, really important, fundamental, atomic concept. One that I have yet to say I've "Mastered". Heh.
Jon Gauthier
Feb 26, 2012 rated it really liked it
Shelves: programming
I've been writing regexes for years, but this book still offered new information on the in-depth workings of regex engines and how to optimize expressions by taking advantage of the engine's strong areas.

If you think you already have a good understanding of regular expressions, you can safely skip to chapter 4. The author includes cross references everywhere, so you can still catch up on some minor detail you may have missed.
Nov 02, 2012 rated it really liked it
This is not a book *only* about RE but also about the differences in how the main RE engines work. It's written in a slow peace that allows for an easy reading without passing from beginner to absolute complexity.
And don't be frightned by the number of pages since the last 200 or so are about particularities in 4 differente languages that you, as me, may not read until really needed.

That being said, is a great book to get a deep insight in RE.
Puneet Singh
Jan 29, 2016 rated it really liked it
Shelves: will-read-again
It gives you a in-depth insight about regular expressions and how to optimize them. It manage to show that how regular expression work for different types of expression engine and languages. To understand the regular expression properly some chapters of it needed to read more than once. This book is lacking a 5 star from my side because the version of book is very old and there are some obsolete examples in few places.
Mar 27, 2009 rated it it was amazing
I thought I was pretty good at regular expressions, but this book puts me to shame. It also makes me glad that I don't have to worry about optimizing them or using them for anything besides quick REPL-type things. Fantastic for anyone who does need a deeper knowledge of regexen. Still quite good for people at my level, where more technical knowledge is helpful, even if it isn't necessary.
Oct 15, 2011 rated it really liked it
Shelves: reference-books
Before O'Reilly started trying to be hip and cool and coining terms like "Web 2.0", they used to write books that didn't suck. This is one of them.

Think you know regular expressions? This book isn't a simple introduction that fades out somewhere near character classes. It's called "Mastering Regular Expressions", and that indeed is it's intent.
Feb 03, 2012 rated it really liked it
I didn't read the book right through, as certain content was not applicable to my knowledge at this point in time, but I found the writing style, information level provided and detail of explaination to be fantastic from this book. Really happy to have found it, currently got this in eBook format but likely to buy it paper format for my desk.
Manny Tingplants
Oct 14, 2014 rated it it was amazing
Shelves: compsci
An entirely higher scope of explanation of regular expressions than any snippet you'll find in the manual or help docs for any particular programming language. J. Friedl is clear, as concise as possible given the subject matter, and a witty pleasure to read. If you have text that needs processing, this is your book.
Ahmad Bamieh
Aug 25, 2017 rated it it was amazing
I've read so many books about regular expressions; this one is definitely the go-to book for deeply understanding regular expressions and its inner nuances.
- Brief and fun History on regular expressions!
- Regular expression flavors and features.
- DFA and NFA engines explanation.
- Measuring the performance of regular expressions.
Aug 31, 2008 rated it it was amazing  ·  review of another edition
Reading this was fantastically useful, I finished just recently but the new knowledge has already earned its keep. It's like taking an intro class on the history and implementation of regex engines from an excellent professor, sans homework and exams.
Doug Alcorn
Jun 26, 2014 rated it really liked it
Back when I read this book it was truly fantastic. No one else had ever dove as deeply into regular expressions. I don't think anyone has since either. However, regexps play a less crucial role than they used to. I still think the book is worth reading if only to get over your fear of regexps.
« previous 1 next »
topics  posts  views  last activity   
Like this book? Join the O'Reilly Media Fan Page 1 11 Oct 28, 2009 09:23AM  

Readers also enjoyed

  • Refactoring: Improving the Design of Existing Code
  • Clean Code: A Handbook of Agile Software Craftsmanship
  • Java Puzzlers: Traps, Pitfalls, and Corner Cases
  • Code Complete
  • Fluent Python: Clear, Concise, and Effective Programming
  • The C Programming Language
  • The Clean Coder: A Code of Conduct for Professional Programmers
  • Pro Git
  • Design Patterns: Elements of Reusable Object-Oriented Software
  • Programming Perl
  • Hackers & Painters: Big Ideas from the Computer Age
  • Java Concurrency in Practice
  • Introduction to Algorithms
  • The Practice of Programming (Addison-Wesley Professional Computing Series)
  • Cracking the Coding Interview: 150 Programming Questions and Solutions
  • Grokking Algorithms An Illustrated Guide For Programmers and Other Curious People
  • Clean Architecture
  • Compilers: Principles, Techniques, and Tools
See similar books…

Goodreads is hiring!

If you like books and love to build cool products, we may be looking for you.
Learn more »
Jeffrey worked for Omron Tateishi Denki (1989-1997) and Yahoo! Finance (1997-2005), but now lives in Kyoto, Japan with his family.

News & Interviews

They’re baaaaaaack! Young adult vampires, that is. Fifteen years after Stephenie Meyer’s Twilight took the world by storm, we’re seeing a brand...
44 likes · 22 comments
“Just as there is a difference between playing a musical piece well and making music, there is a difference between knowing about regular expressions and really understanding them.” 0 likes
“$/ = ".\n";
while (<>) {
next if !s/\b([a-z]+)((?:\s|<[^>]+>)+)(\1\b)/\e[7m$1\e[m$2\e[7m$3\e[m/ig;
s/^(?:[^\e]*\n)+//mg; # Remove any unmarked lines.
s/^/$ARGV: /mg; # Ensure lines begin with filename.
More quotes…