Mastering Regular Expressions
Powerful Techniques for Perl and Other Tools
By Jeffrey E. F. Friedl
January 1997
Pages: 368
ISBN 10: 1-56592-257-3 |
ISBN 13: 9781565922570
![]()
![]()
![]()
![]()
(5) (Average of 7 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.
Regular expressions, a powerful tool for manipulating text and data, are found in scripting languages, editors, programming environments, and specialized tools. In this book, author Jeffrey Friedl leads you through the steps of crafting a regular expression that gets the job done. He examines a variety of tools and uses them in an extensive array of examples, with a major focus on Perl.
Full Description
- Scripting languages (including Perl, Tcl, awk, and Python)
- Editors (including Emacs, vi, and Nisus Writer)
- Programming environments (including Delphi and Visual C++)
Register your book | Submit Errata | Examples
Browse within this book
| Table of Contents | Index | Sample Chapter | Colophon
Book details
First Edition: January 1997
ISBN: 1-56592-257-3
Pages: 368
Average Customer Reviews: ![]()
![]()
![]()
![]()
(5) (Based on 7 Reviews)
Featured customer reviews
Mastering Regular Expressions Review, June 25 2002
Well authored and well edited. The 2 years of effort the author says he gave
this book really shows itself. He sells you on the benefit of "hanging in" there through the book, as well as the world of programming power which will be available to you when you indeed "master" regular expressions. Mr. Friedl is sensitive to the various levels of programming expertise his readers will come to the book with. Examples given are strenuously explained--something a budding programmer like myself really appreciates, with nobody to turn to to have my many questions explained. I've never gotten INTO a computer book like I have this one. My deepest appreciation to the author. If he ever attempts another topic I would like to know about it just out of respect for his work ethic as an author. Very impressive.
Mastering Regular Expressions Review, April 25 2002
Terrific!
I bought the book with the intention of using it as a refrence and before too long I had read it from cover to cover.
Mastering Regular Expressions Review, February 15 2002
This book isnt good. To call it such would be an insult to the author and OReilly. This should be the standard for technical books. Content, style, and delivery are so near perfect it makes other excellent technical books look mediocre. Great job Jeffrey and OReilly!
If you at the point in your programming where you are ready to go beyond simply using Regular Expressions to actually understanding them you need this book. If you are just getting started with Regular Expressions you will be ready for anything with this book at hand.
Mastering Regular Expressions Review, October 24 2001
It's fantastic. Cannot explain, with, more, words.
Mastering Regular Expressions Review, July 30 2001
WOW!
What an incredible book to read. Jeffrey Friedl made a big effort to describe a not so easy programming technique, into a full comprehensive matter. This isn't an easy subject to write about. The author made a very interesting gift to us all.
The book would need an update though.
Mastering Regular Expressions Review, February 22 2001
This is an exceptional book. Mr. Friedl has the rare ability to take a potentially dry subject like Regular Expressions and produce and enlightening, entertaining, and thoroughly addicting book. I especially like his conversational style and inclusion of humorous anecdotes like his experience explaining the term "Regular Expressions" to his Japanese colleagues.
If you don't already know Regular Expressions, you need this book. If you think you already know Regular Expressions like the back of your hand, you really need this book!
Mastering Regular Expressions Review, November 18 2000
Have you ever had a school teacher that just loves what he or she is teaching? Loves it so much the lessons become interesting no matter how tedious or difficult the matter of the lessons are? Well, this is a book written in that sprit. I never expected regexes to be fun, but now I am a addict ...
This is a tough book to read through, but it is well written and even a non-programmer like me can enjoy it. On and off it goes so deep into the magic world of regexes I loose my directions, but for the most part it is reasonable hands-on and does teach a lot of good regex common sense.
If you really want to utilise regexes for getting things done -- beyond what search and replace in word processors provide -- this book is a must have. And fun: I had never realised the impact of a thing such as nothingness before I read this book ...
Mastering Regular Expressions Review, April 21 2000
Submitted by TEd BROWn [Respond | View]
Two words: Deep Magic.
Mastering Regular Expressions Review, April 21 2000
Submitted by TEd BROWn [Respond | View]
Two words: Deep Magic.
Mastering Regular Expressions Review, August 24 1999
Submitted by Chris X Edwards [Respond | View]
I did read it straight through up to chapter 7 (which was ostensibly Perl-centric). I felt like much of the material here was for the benefit of people like Larry Wall and John Ousterhout. I'm no dummy (I once wrote a crude "search & replace" facility for an HP48 calculator of all things), but a lot of material was a bit beyond what I would need. I just wanted something to help me do what I needed to do in vi without reading the help docs which don't help at all.
Fortunately everything a mere mortal would ever have to worry about regular expressions is explained quite explicitly in the first 50 pages. Buy the book, read the first 50 pages, learn a lot, and impress your colleagues who browse through the rest of the book...unless you actually are a programming language programmer.
Mastering Regular Expressions Review, August 21 1999
Submitted by Dave Hummel [Respond | View]
Tripled my knowledge of regular expressions in just a few pages, and I haven't even finished the whole book. Don't bother trying to learn perl without this book unless you are already a regex Guru!
Mastering Regular Expressions Review, December 29 1998
Submitted by Grant Hopwood [Respond | View]
I found this book fantastic. It opened my eyes to the 'real world' of regular expressions, that I never knew before.
This book gave me all the knowledge I needed about how the perl regex engine performs its pattern matching. How to write accurate and effective regexes.
I often manipulate text files hundreds of megabytes in size, and this book was a great lesson in how I could optimize the regexes I was using. Even so much as tripling their processing speeds!
Thanks Jeff!
Mastering Regular Expressions Review, August 29 1998
Submitted by Julian Olson [Respond | View]
The book is a spectacular achievement. I ordered it after
reading the TPJ { The Perl Journal } article. I have used
AWK (Thompson Automation compiler) a lot, only recently
discovered PERL, and now feel extremely lucky to have my
eyes opened further by what you have written. You have
struck exactly the right level, and the writing is a
beautiful reflection of clear thinking.
Media reviews
"Jeffrey Freidl's book is not a dummies guide; it demands concentration, but it is a good read in its own right. Even though it is intended for programmers working with regex-supported languages and programming environments, it is a valuable resource for informed lay-readers who would like to explore this fascinating field. As the only reference to the art, it should be on the bookshelf of every programmer and anyone who works with large text files."--Major Keary, Book News, 2002 No 5
"Mastering Regular Expressions by Jeffrey Friedl is quite possibly the best programming book I have ever been fortunate enough to read. A straight forward style, combined with an uncanny ability to make sense of what can be a very confusing subject, all combined with the power of getting control of regular expressions make this book a must buy, Covering regular expressions in such a comprehensible way makes this book a must buy all by it's self, but coupling that with the keen insights and real world examples used for Perl and other programming give this book a permanent place on my desktop." --Wes Ritchey, The Internet Eye Magazine, Dec 2000
"The definitive work on regular expressions is Mastering Regular Expressions by Jeffrey E. F. Friedl. For those who want to get the most out of working with regular expressions, I highly recommend this book." --Brad Merrill, January 2001
"This book is a masterpiece-one I would highly recommend for your technical library, especially if you write Perl Scripts."-Gene Wilburn, Computer Paper, June 2000
"I very much enjoyed reading this book, and certainly learned a lot, even about Perl." --Tom Christiansen, co-author of Programming Perl
"Mastering Regular Expressions" is destined to be a classic reference on the subject it covers. If you're just getting started with regex, this book will save you a lot of time (and grief). If you are already using regex, it will help you extend your ability and understanding." --Dr. Dobbs, December 1997
"And you thought you were a regular expression guru, eh? 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.... Decorum prevented me from saying what I really thought: I hate your book! It continues to expose my utter ignorance on a subject about which I previously thought I had a clue." -- Bob Nelson, Dallas, TX
"Mastering Regular Expressions is very instructive and (surprisingly, to me, a professor of literature) a lot of fun. I'm reading it straight through, as you suggest, and finding it to be very entertaining." --Richard Shroyer, Research Director and Professor of English, Univ. of Western Ontario, London, Ontario, Canada
"The book has been really helpful. I was always scared of regular expressions before and wrote a lot of extra code to get around using them. Now, I try to find a way to use regular expressions to solve every problem." --Roman Milner
"Master Regular Expressions is a superior book. Author Jeffrey Friedl has produces a current, well-written, precise addition to the O'Reilly repertoire, with a volume completely devoted to text and data manipulation. It provides the perfect complement to CGI and Delphi programs and their accompanying texts.... I highly recommend it for anyone and everyone involved with regular expression manipulation." --Sys Admin, April 1997
"This book is important because regex is so intimidating, and Freidl make it much easier to understand. Many programmers don't use the regex available in their development tools. Chances are, regex will save you a lot of time when you find yourself stuck with a pile of someone else's source code that you need to maintain. If you're just getting started with regex, this book will save you a lot of time (and grief). If you are already using regex, you will extend your ability and understanding." --Dr. Dobbs Journal
"Many thanks, and renewed compliments on your wonderful books; I saw
Mastering Regular Expressions in Melbourne, Australia, and could hardly restrain myself from buying it there and then (at great financial punishment; books in Australia cost bags of gold; I waited, and bought it at the bookstore on the Apple Computer campus as soon as I got back). What a nifty book. I hope I can use that in a course some time, too." -- Professor Geoffrey K. Pullum, Stevenson College, UCSC, Santa Cruz, CA
"A stupendous tour de force of all aspects of pattern matching. With an impeccable eye to the tiniest significant detail, the author covers topics ranging from the subtle differences among NFA, DFA, and POSIX NFA matching behaviors to the practical distinctions of how varying versions of grep, sed, awk, emacs, tcl, python, and perl behave. The author at all times connects theory to practical application of this knowledge in daily programming." --Tom Christiansen, Camel Critiques
"Novice DOS users tend to find out reasonably quickly that "*.*", when used as an argument with the delete command, means "everything". Intermediate users will have found that "?????.exe" matches programs with filenames under six characters long, and that "*." finds directories (since novices usually don't give directory names extensions). Advanced users know that if you want to find a file which has "LAN" somewhere in the name you need to use "?????LAN?????.*". DOS wildcards, though, are only the crudest approximation to the power of the algorithmic matching that can be done with regular expressions used in UNIX and UNIX derived applications. "As the author points out, documentation on regular expressions is abundant, but not very good. In addition, there are differences between the use of regular expressions in different applications and different versions of the same application. "Friedl provides a realistic, reliable, and very readable introduction and overview of the topic. The use of humour not only leavens the text, but supports the concepts being addressed. The material is comprehensive, and covers differences in the use of regular expressions both in sections dealing with specific functions, and in a separate chapter which details usage in awk, Tcl, and emacs. (Perl gets a chapter all to itself.) Readers may pursue the topic as they wish, of course, but Friedl's offer of mastery extends to a chapter on *how* matching is done: the internals of regular expressions. "Definitely, a valuable addition to the UNIX bookshelf, and also of use to those working with grep, awk, Perl and the like on other platforms." --copyright Robert M. Slade, 1997
"In the forties, Warren McCulluch and Walter Pitts created neuron-level models of how the nervous system operates. The mathematician, Stephen Kleene, later described these models using his mathematical notation called regular expressions. Ken Thompson incorporated that system of notation into qed (the IBM 7094 grandfather of the UNIX ed) and eventually into grep. Ever since that time, regular expressions have constantly seeped into UNIX and UNIX-like utilities. These are the regular expressions that are not used to explain nerves; these are ones used to get on them.
"Grep, egrep, vi, sed, lex, awk, emacs, Perl, Tcl, and Python support regular expressions. In fact, regular expressions (regexes) are an essential part of these utilities. Unfortunately, regexes usually don't seem very important in the documentation. Man pages only casually mention regexes with usually no theoretical explanation and very limited practical discussion. This leaves most of us crafting regexes like we're playing the board game Battleship -- keep guessing until we sink a solution.
"Mastering Regular Expressions is an important work about an often overlooked concept that permeates UNIX: the regular expression. It is clear and practical. The regular expression is explained by concept and not by rote. Friedl is trying to get us to think in regular expressions and not to blindly parrot (or pirate) his examples.
"The book uses quick do-you-really-understand questions at key spots in the text. The book is constructed so that you have to turn the current page to see the answer to a question. Unfortunately, this prevents the 'accidental' hint. Be honest. It's human nature to have wondering eyes when a question is too hard. If you can't answer a question in this book, then you know for a fact that you can't answer it. It's too hard to 'accidentally' turn a page.
"That's only one example of its thoughtful design. The typography is the best use of typography as a communication tool that I have seen. With code snippets like 'if ($input=~m/^([-+]?[0-9]+(\.[0-9]*)?)([CF])$/)', the typography takes you by the hand with a series of underlining, shading, and contrived characters that highlight important sections of the code. Whereas in most books the 'Typographical Conventions Used' section is fluff, read and memorize this section before you cross the river regex with Friedl. You can't journey to the other side without it.
"So, what exactly is a regular expression? What makes it regular? Don't look for those answers here. Friedl gives you practical concepts, not a theoretical framework. He defines regular expressions as 'the key to powerful, flexible, and efficient text processing.' He clarifies that with 'regular expressions... allow you to describe and parse text.' That is the closest thing to a definition of regular expressions in the book. That is also like defining the sun as our source of heat and light, but failing to mention that it is the ball of flame in the center of the solar system. The title of the book is not The Theory of Regular Expressions but Mastering Regular Expressions. Look for practical advice on crafting efficient regexes at your desk and not for conversation tidbits in the break room."
-- Don Bryson (dbryson@tclock.com) Copyright 1997 Dr. Dobbs Electronic Review of Computer Books (http://www.ercb.com/)
"There's no better resource than Jeffrey Friedl's Mastering Regular Expressions (O'Reilly 1997) a great source of sample expressions and detailed explanations of how regular expressions work their magic." --Jason Snell, MacWorld, Nov 1998