BUY THIS BOOK

Safari Books Online

What is this?

Looking to Reprint this content?

Mastering Regular Expressions, Second Edition

By Jeffrey E. F. Friedl
Second Edition  July 2002 
Pages: 484
ISBN 10: 0-596-00289-0 | ISBN 13: 9780596002893
starstarstarstarstar (Average of 5 Customer Reviews)

This book has been updated—the edition you're requesting is OUT OF PRINT. Please visit the catalog page of the latest edition.

The latest edition is also available on Safari Books Online.

Book description

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, Java, VB.NET and C# (and any language using the .NET Framework), PHP, Python, Ruby, Tcl, MySQL, awk, and Emacs.

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.


Full Description

Regular expressions are an extremely powerful tool for manipulating text and data. They have spread like wildfire in recent years, now offered as standard features in Perl, Java, VB.NET and C# (and any language using the .NET Framework), PHP, Python, Ruby, Tcl, MySQL, awk, Emacs, and many other popular tools and languages. 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. In spite their wide availability, flexibility, and unparalleled power, regular expressions are frequently underutilized. 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. A command of regular expressions is an invaluable skill. 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. 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. Mastering Regular Expressions, Second Edition has been thoroughly updated to include all the new features of Perl 5.8, as well as several other languages, including Java, VB.NET, C#, Python, JavaScript, Tcl, and Ruby. Written in the lucid, entertaining tone that made a complex, dry topic crystal-clear to thousands of programmers, and sprinkled with solutions to complex real-world problems, Mastering Regular Expressions offers a wealth information that you can put to immediate use. 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

Browse within this book

Cover | Table of Contents | Colophon




Featured customer reviews

Write a Review


Superb book,  November 18 2005
Rating: StarStarStarStarStar
Submitted by Anonymous Reader   [Respond | View]

If you use regular expressions, you'll love this book.

If you don't use regular expressions, this book will open your eyes to a much faster and cleaner way of doing a lot of what you probably struggle with every day.

Not only have I read it through, cover-to-cover, twice - I have permanent bookmarks in the book so I can find the parts I use all the time (the Perl section is particularly useful). Reading this book (and it's companion pocket reference) has saved me literally hours of time on some jobs, and made others possible. Some co-workers made fun of how much I read it - until they needed to understand a regular expression in someone else's code. Now they think it's wonderful.

Some of the best parts include details on the differences between Perl, grep, vi, Java, etc. Very well done. The examples are superb, and the occasional "quiz" lets you make sure you're really understanding what he's talking about. The author also includes references to other pages (instead of making you remember where you saw something


From zero to complete in one day!,  July 10 2004
Rating: StarStarStarStarStar
Submitted by Christopher Nurse   [Respond | View]

This book has transformed the way I plan to write applications. Whereas before I would have had major areas of hardcoded logic, I can now write scripts that can be parsed using regex stuff I have learned from this book.

This makes my applications "soft", it opens up major areas of functionality that can become user customisable, where the customisations can be validated, to bullet proof the application against syntax errors.

In short, think regex, as the author says, open your mind and a whole heap of new possibilities will be yours!


Lucas Gonze photo Amazing,  June 28 2004
Rating: StarStarStarStarStar
Submitted by Lucas Gonze   [Respond | View]

Friedl's obsessiveness is mind blowing, and the result is a remarkable book. He took the trouble to invent new typographic conventions. He constructed, somehow, a compelling narrative flow and informal voice in a book on a very dry topic. The examples illustrate perfectly. The history of regular expressions is comprehensive. Etcetera ad superlativim.

On a practical level I found this book had an impact on my working life. It's useful. But leaving aside the value of advanced regular expressions or of this book in helping you to master them, it is an absurdly well made guide, definitive not just on the topic but also on as an example of technical writing.

Read all reviews


Mastering Regular Expressions, 2nd Edition Review,  February 06 2004
Rating: StarStarStarStarStar
Submitted by George Woolley of Oakland.pm   [Respond | View]



If regular expressions are important to you, get this book.

"Mastering Regular Expressions" is exceptional

both in the scope of what it covers regarding regular expressions

and also in it's thoroughness.

To date this is the most impressive technical book I've read on any subject.

It's a virtuoso performance.

One caveat: parts of the book are quite demanding.

See my longer review for more detail.


Mastering Regular Expressions, 2nd Edition Review,  October 13 2002
Rating: StarStarStarStarStar
Submitted by Larry Bezeau   [Respond | View]

The second edition of Mastering Regular Expressions is

undoubtedly the most thorough and unified coverage of this important

topic. A treatise such as this is appropriate in light of the large

number of programs, both interactive and command line, that use regular

expressions with feature sets that vary from program to program. Many

references on specific languages contain chapters on the use of regular

expressions within the language, but they lack the unifying thrust of

this book. Friedl's book also considers the issue of efficiency in the

use of regular expressions, a topic not normally examined elsewhere.

The book covers regular expressions in general followed by specific

coverage of regular expressions in three languages, Perl, Java, and .net.

A major omission here in my view is JavaScript. The newer versions of

JavaScript have a powerful regular expression capability and, unlike the

other languages considered, JavaScript occurs in a context where there is

no other choice of language, in interactive pages in web browsers. Another

language that gets short-changed is TCL (Tool Command Language) which has

a very powerful and efficient regular expression capability. My own

perference would have been for coverage of these two languages over the

the three chosen by the author.

There is a chapter on solving practical problems but I would have preferred even more on this topic. Little mention is made of utilities

such as sed that depend entirely on regular expressions for their usefulness.

To the author's credit, he does document carefully many of the traps into

which regular expression programmers frequently fall.

Many consider regular expressions to be inelegant but they are

much more concise than the alternatives and are often used where there

is no other reasonable choice. If you find yourself in this situation,

and especially if you are using regular expressions in more than one

language or utility, you will benefit from reading this book. It is

well organized and readable.

Larry Bezeau

University of New Brunswick


Media reviews "A real tour-de-force of a book which not only covers the mechanics of regexes in extroadiary 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," November 2003

"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, javaranch.com, March 2003

"An excellent guide to using regular expressions, not only for .Net, but also in Java and Perl...this a valuable book for anyone who needs to master regular expressions."
--Huw Collingbourne, PC Plus, March 2003

Read all reviews

See larger cover