Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


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 over your data. If you already use them, you'll appreciate this book's unprecedented detail and breadth of coverage. If you think you know all you need to know about regular expressions, this book is a stunning eye-opener.

As this book shows, a command of regular expressions is an invaluable skill. Regular expressions allow you to code complex and subtle text processing that you never imagined could be automated. Regular expressions can save you time and aggravation. They can be used to craft elegant solutions to a wide range of problems. Once you've mastered regular expressions, they'll become an invaluable part of your toolkit. You will wonder how you ever got by without them.

Yet despite their wide availability, flexibility, and unparalleled power, regular expressions are frequently underutilized. Yet what is power in the hands of an expert can be fraught with peril for the unwary. Mastering Regular Expressions will help you navigate the minefield to becoming an expert and help you optimize your use of regular expressions.

Mastering Regular Expressions, Third Edition, now includes a full chapter devoted to PHP and its powerful and expressive suite of regular expression functions, in addition to enhanced PHP coverage in the central "core" chapters. Furthermore, this edition has been updated throughout to reflect advances in other languages, including expanded in-depth coverage of Sun's java.util.regex package, which has emerged as the standard Java regex implementation.Topics include:

  • A comparison of features among different versions of many languages and tools

  • How the regular expression engine works

  • Optimization (major savings available here!)

  • Matching just what you want, but not what you don't want

  • Sections and chapters on individual languages

Written in the lucid, entertaining tone that makes a complex, dry topic become crystal-clear to programmers, and sprinkled with solutions to complex real-world problems, Mastering Regular Expressions, Third Edition offers a wealth information that you can put to immediate use.

Reviews of this new edition and the second edition:

"There isn't a better (or more useful) book available on regular expressions."

--Zak Greant, Managing Director, eZ Systems

"A real tour-de-force of a book which not only covers the mechanics of regexes in extraordinary detail but also talks about efficiency and the use of regexes in Perl, Java, and .NET...If you use regular expressions as part of your professional work (even if you already have a good book on whatever language you're programming in) I would strongly recommend this book to you."

--Dr. Chris Brown, Linux Format

"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...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. Ten out of Ten Horseshoes."

--Jason Menard, Java Ranch

Subscriber Reviews

Average Rating: 4.909090909090909 out of 5 rating Based on 11 Ratings

"Simply superb" - by Philip Storry on 20-AUG-2010
Reviewer Rating: 1 star rating2 star rating3 star rating4 star rating5 star rating
Regular expressions are an incredibly powerful tool.

But they can also be complex, dangerous and subtly different from implementation to implementation.

This book is a superb guide through the topic.  It's well written and guides you though the minefields, yet is also a good reference.

This rarely leaves my Safari bookshelf.  For those moments when you're wondering just why a huge regular expression isn't working, this book brings clarity and understanding.

It should be regarded as essential reading for anyone trying to match text within a stream of text.

Report as Inappropriate

"Mastering Regualr Expressions, 3d edition" - by Maksim Abuajamieh on 24-NOV-2009
Reviewer Rating: 1 star rating2 star rating3 star rating4 star rating5 star rating
The author did an excellent job turning a dry and complex topic into a really interesting and fun to read book!

I think this book is a Must-Have for every system administrator and programmer.

I hope there will be a new updated edition of this book soon since it is more than 3 years old now.

5 stars book!

Report as Inappropriate

Table of Contents



The publisher has provided additional content related to this title.


Visit the catalog page for Mastering Regular Expressions, 3rd Edition

  • Catalog Page

Visit the errata page for Mastering Regular Expressions, 3rd Edition

  • Errata