Regular Expressions for Regular Programmers

June 8, 2009

If you've followed my blog for any length of time, you know that I am a total regular expression fanboy. It's almost embarrassing how much I love the damn things. I'm pretty sure my teammates roll their eyes every time they see yet another class I've touched that has using System.Text.RegularExpressions at the top. You might as well rename it to JeffHasBeenHere.

I say that because I end up writing a lot of string handling code, even when people tell me I shouldn't. Now, I only advocate responsible and judicious use of regular expressions when you happen to be dealing with strings. In the wrong hands, regular expressions can be dangerous. You might end up wondering if Q*Bert just vomited all over your source code. Or you might be programming in Perl. Is there any difference? (instant rimshot)

But I digress. Although I love regex, I've never been a fan of the classic regular expression reference book, Friedl's Mastering Regular Expressions. I found it dry, a bit academic, and lacking in practical real world examples. It just didn't speak to me as a working programmer in the way that regular expressions themselves did, and that was disappointing.

That's why I was so excited to discover that two of the gnarliest regex gurus I knew – Jan Goyvaerts (author of RegexBuddy and regular-expressions.info) and Steven Levithan (author of XRegExp and RegexPal) – were putting their heads together to create a regular expression reference for the rest of us. I immediately pre-ordered it sight unseen.

That book is Regular Expressions Cookbook. It arrived a few days ago, and although my expectations were high, I think this book has exceeded even the loftiest expectations I had. It is outstanding.

regular-expressions-cookbook.png

What I love about this book is twothree things:

  1. It's filled with practical, real world examples of RegEx use. At every step of the way, from beginner to master level, you're building regular expressions that are actually useful in the wild, and not just abstract, obtuse academic exercises in solving string matching puzzles.

  2. It covers all the common gotchas that you inevitably run into when you start building non-trivial regular expressions. Things like the sometimes massive (and painful) differences between regex libraries in various languages, subtle regex flavor quirks, catastrophic backtracking, unicode support, and so forth. These are all presented in context of the solutions, exactly as you'd encounter them in real programming. I know because I have the scars to prove it.

  3. It was updated and revised in the second edition to reflect current flavor differences with new recipes, plus a whole new chapter on source code and log files. It also covers XRegExp, an emerging standard, fully-featured regex library for JavaScript.

Regular Expressions Cookbook manages to be simultaneously accessible and almost ridiculously comprehensive. I consider myself a fairly advanced regex user and about 50 pages in I've already had three big "oh, wow, I didn't realize that" moments. In my mind, at least, this completely replaces the Friedl book as the go-to reference for programmers of any skill level or background who seek regular expression enlightenment.

Needless to say, recommended.

Posted by Jeff Atwood
110 Comments

Does it have a recipe for cake? CakePHP that is. I use RegexBuddy 3 and I have lists of useful regular expressions in my notes.

Robert S. Robbins on June 9, 2009 2:21 AM

I hate them. Nothing shows more the pure snobery of geeks. Because they were able to master this intellectual perversion they feel they are superior, huh get a life.
It's not that they don't have their uses, but in 9 of 10 times other methods should be used.
The main problem I see in them is their lack of standardisation, when you talk about Regex, do you mean perl regex (v5, v6), sed regex, any other implementation (Microsoft, and Oracle come to mind).
I didn't choose these implementation randomly, we have in our system (the biggest translation memory system in the world) all of them, and every time something fails, it's almost ever these f... regexes that missed some corner cases or some subtle semantic differences between the implementations. The other problem is to find where the error was, when they fail, they do not fail in a simple way, they mangle a little bit their data and what happens after that is random. I prefer ou C apps, when they fail (which they do not anymore) they fail for real, core dump and all. But the bugs are corrected within minutes.

Sorry if I sounded rude, but there were too much agreement here, that's not sane ;-)

gallier2 on June 9, 2009 2:23 AM

i always mutter to my colleagues, "Stop me, i'm about to use another regex..."

i think regex's benefit more than any other code from unit testing.

not that i always do that, because i often think "nah, not this time, it's so simple!" -- the crazy edge cases often come back to bite.

(plus, love the fact that now, by mousing over a commenter's name, i can see the url of their site. Nice improvement)

secretGeek on June 9, 2009 3:14 AM

> three big "oh, wow, I didn't realize that" moments

That tells a lot. I'd personally interpret that as the commonly observed fact that Regular Expressions are vastly underestimated. They are far more powerful than they seem. And that would be Powerful as in Chainsaw, not just Powerful as in Biceps.

Like anything powerful it will hurt the one who wields it uncautiously.

By the way, @DevMan: that's actually why the name is very good. It describes the academic properties of these expressions: RE (BRE or ERE) (much like indicators like LA(LR), LL(n) are used to indicate the power of a parser).
Like so many scientific notions, the name can be deceptive, for the uninformed

seth@mailinator.com on June 9, 2009 3:17 AM

> I found the infallible logic of ConkCurrency irresistibly hilarious (not a good thing).

Neither is an Ad-hominem attack a good thing.

> Why wouldn't you be able to purchase an ebook in India from the site in US? You can most certainly get a PDF.

You missed the whole point - fair price as an instrument against copyright infringement, so to speak.

The fact that there are EEE's shows that publishers hold the concept of variable pricing valid. It's older than at least two decades.

> You can also find the same material online: regular expressions in all shapes and sizes.

As if this post is only about regular expressions. It appears to be more about the book. You seem to have realised that - talking of clicks and whatever else - but not put 2 and 2 together - to realise the comment was about fair price based on lifestyle.

If your Feds screw up any further, it wont sound so hilarious. Trust me, it won't. Check out what happened to Brazil and Japan in the late 90s.

There are countless places to learn regex for free on today's web. Does Jeff not know that? Sure he does. I know that too. But this is a good time to get good people - authors of a book on a strictly hacker realm - to read about and take note of this bigger problem which they may not have given a priority to. And in general to increase awareness of this issue. India is one country.

The dollar is expensive in many more countries - many that do _not_ take outsourced jobs from you, so you have no reason to perceive a threat from them.

Do you realise that if everyone outside US/UK buys these books at small prices, authors still stand to gain more money?

This is also a nice way to reciprocate the freebies they give us - in clear words, suggesting a way from which they could get that much more income and thus more encouragement to produce better works.

All this thought goes behind writing a simple suggestion. If you do not give a new idea any thought, how are you going to invent anything?

Apologies for the personal response.

ConkCurrency on June 9, 2009 3:21 AM

> Uh, what? But it's on your recommended reading list: http://www.codinghorror.com/blog/archives/000020.html

The Friedl book was the best of the available options at the time (2004); I'll switch it out ASAP.

Jeff Atwood on June 9, 2009 4:33 AM

> The Friedl book was the best of the available options at the time (2004); I'll switch it out ASAP.

Ouch

Jeffrey Friedl on June 9, 2009 4:49 AM

Mr. Friedl: don't sweat too much, you've got a lot of fans. I am one. I admit I'm going to check out the Cookbook too, on the grounds that you can't get too much of a good thing.

A. L. Flanagan on June 9, 2009 5:25 AM

Been a reader for a while but just bought this on your recommendation, RegEx has never quite been accepted by my brain, hopefully this will finally do it!

Alex on June 9, 2009 5:59 AM

Jeffrey Friedl introduced me to the folks at O'Reilly, and has been very supportive of my and Jan's previous work. He was also one of the technical reviewers for Regular Expressions Cookbook, and provided a harsh critique that helped us make some improvements. I appreciate Atwood's great comments about this book, but honestly, Friedl's Mastering Regular Expressions is perhaps my favorite techical book--and it's a must read for serious regexers.

@Kris, O'Reilly picks the covers. More specifically, Edie Freedman (according to http://oreilly.com/news/ediemals_0400.html).

@Roger, Jeff never approached us about this post, nor vice versa. And he bought it himself (according to this post), although I'm sure O'Reilly would've been happy to provide a free reviewer copy (email them if you're interested in this sort of thing).

Steven Levithan on June 9, 2009 6:53 AM

First.

David on June 9, 2009 7:25 AM

@ConkCurrency: Contact your favorite publisher of technical books in India and ask them to buy the rights from O'Reilly to re-publish the book in India in a format and at a price suitable for the Indian market.

Jan Goyvaerts on June 9, 2009 7:27 AM

Also, if you're wondering what the $&!@( that nasty looking thing on the cover of the book is:

It's a Musk Shrew.

http://en.wikipedia.org/wiki/Crocidura

Not sure why the Friedl book gets the cool wise Owl while Jan and Steve get a freakin' rat. I guess them's the breaks..

Jeff Atwood on June 9, 2009 7:33 AM

David, you are last in life though. Congrats.

Todd on June 9, 2009 7:39 AM

I personally think that the Musk Shrew is cute! I wish each copy came with either a plush or real Musk Shrew. I'd be willing to shell out an extra $4.99 for that!

Sam on June 9, 2009 7:52 AM

Here is an interactive web-based regex tester.

http://www.gskinner.com/RegExr/

Jordan on June 9, 2009 7:56 AM

There's a funny post where an author of an O'Reilly book takes issue with the creature on the front. This is a link to an F# blog - Chris Smith's completely unique view:
http://blogs.msdn.com/chrsmith/archive/2009/02/02/petition-for-programming-f-s-book-cover.aspx

Also, Jeff, so you know, you're responsible for me running out and buying Regex Buddy.

J on June 9, 2009 7:57 AM

I like the Musk Shrew! :)

Mohit Nanda on June 9, 2009 7:58 AM

"I've never been a fan of the classic regular expression reference book, Friedl's Mastering Regular Expressions."

Uh, what? But it's on your recommended reading list: http://www.codinghorror.com/blog/archives/000020.html

Sean Devlin on June 9, 2009 8:04 AM

And to follow up...
Here is what the cover ended up being
http://blogs.msdn.com/chrsmith/archive/2009/05/13/programming-f-official-cover.aspx

J on June 9, 2009 8:05 AM

I'll have to give this a read. Also, does anyone have a recommendation for a book about writing/implementing a regular expression engine? I'm in the middle of 'the Dragon Book' at the moment (which is fantastic), and I'd really like to get deeper into regular expressions; maybe in a less formal way. Though there probably aren't many informal books covering formal language theory.

Will Farrell on June 9, 2009 8:07 AM

Erm, I'm pretty sure I got Friedl's book on a recommendation on your blog! Found it useful too - the 'academic' side of it actually explained how Regexes work, which as a dev I find useful. I want to know 'why' too...

Andy on June 9, 2009 8:07 AM

I do a lot of string handling with string.replace, concat, etc, but I have not considered regex use in almost no-case. It almost make me think how was it again /w or /d and /w{1,10} , (and makes me feel pooof) - that's almost the regular expressions I know. When would it be so good to use regular expressions?

Qurius on June 9, 2009 8:08 AM

Awesome. I will add this to my Safari library. Personally RegEx scares the pants off of me, so something like this could prove useful.

chrisb on June 9, 2009 8:14 AM

Another good book about Regular Expressions is the Friedl book, Mastering Regular Expressions. I can imagine, that this one will show more useful examples (fishes), instead of more general explanations of how to write a regular expressions (teaching how to fish).

Peter Stuifzand on June 9, 2009 8:15 AM

using JeffHasBeenHere = System.Text.RegularExpressions;

Chris Doggett on June 9, 2009 8:15 AM

Enjoy your kickback, I've been needing to put a book on regexes onto my shelf for some time.

Matt Mousseau on June 9, 2009 8:21 AM

"I've never been a fan of the classic regular expression reference book, Friedl's Mastering Regular Expressions. I found it dry, a bit academic, and lacking in practical real world examples."

I would have TO ABSOLUTELY AGREE with this one. I brought Friedl's book with me to work as I was trying to solve some difficult string processing and parsing problems and it was just useless I'm afraid to say. I actually made MUCH MORE progress using the Regulator tool http://sourceforge.net/projects/regulator/
instead to give me feedback on why my regex wasn't behaving as I'd like.

o.s. on June 9, 2009 8:22 AM

Although Regular Expressions are really awesome, real men use (LA)LR parsers.

DrJokepu on June 9, 2009 8:29 AM

@Peter Stuifzand: Actually, Regular Expression Cookbook is about 50% "teaching how to fish" in cookbook format, and 50% real-world "fishes" that we've already caught for you.

And while doing my research for this comment I've learned that "fishes" is actually a proper plural for "fish", even though "fish" itself is more commonly used as the plural for "fish".

Jan Goyvaerts on June 9, 2009 8:31 AM

I've never had the need to use regular expressions

Josh Stodola on June 9, 2009 8:43 AM

What annoys me about Friedl's book is that he describes how different regular expression engines work he is wrong. What annoys me even more is that he knows he is wrong, and he tells his readers that he is wrong and that is doesn't really matter. I find that attitude very patronising and scornful towards his readers.

Robert Virding on June 9, 2009 8:48 AM

You should just code your directive like this:

using System;
using System.Text:
using JeffHasBeenHere = System.Text.RegularExpressions;

Hehe...

Christopher Tillman on June 9, 2009 8:51 AM

Regex.IsMatch(strThisArticle, @"pure awesome hell yeah regex") = True

Mikey on June 9, 2009 8:52 AM

does it handle the regex disection of XML files as found here?
http://www.cs.sfu.ca/~cameron/REX.html

Anonymous on June 9, 2009 8:58 AM

I just wanted to say just one more thing about Friedl's book, it isn't a horrible book just not very good for day to day practical problem solving with regexes but very good for understanding the theorectical underpinnings of how regexes work. Unfortunately, for practicing software designers the theorectical exposition isn't as helpful as a recipe format is for solving more hands on issues that arise when trying to craft a working expression to solve a difficult problem under a tight deadline. His book is really written at a level for someone to write their own regular expression library rather than learning them to build a solid fundamental understanding.

o.s. on June 9, 2009 9:00 AM

My first post here, been lurking for months!

Just posting to say: bought :-)

Nigel Smith on June 9, 2009 9:07 AM

@Jan Goyvaerts: Love your PowerGrep product! Tons of regular expression fun with that tool. Thanks, from a paying customer.

Martin C on June 9, 2009 9:12 AM

"Also, if you're wondering what the $&!@ ..."

I started trying to parse that as a regex before reading the rest of the sentence....

Alnitak on June 9, 2009 9:15 AM

"I found it dry, a bit academic, and lacking in practical real world examples. It just didn't speak to me as a working programmer in the way that regular expressions themselves did, and I found that disappointing."

What a coincidence! I wrote something on these lines yesterday :) - see "Two Types of Technical Books" (http://www.hamagudi.com/2009/06/two-types-of-technical-books.html)

Tathagata Chakraborty on June 9, 2009 9:36 AM

Have to agree with the Regex religiolos. Almost also bought Regex buddy because of you J, then realised the vast amount of power will destroy all the other possibilities. Remember; "you now have two problems". That's all for now, good post.. I have not laughed with a blog post like this in a long time.

Cheers,
J

J Beaurain on June 9, 2009 9:39 AM

The most common gotcha I see with regular expressions is when programmers try to make them parse grammars that are more complex than a regular language. No matter how clever your regular expression, it simply cannot singlehandedly parse strings from a context-free, context-sensitive, or recursively enumerable language. Yet people try and try to enlist regular expressions for such tasks, often creating security vulnerabilities.

Adrian on June 9, 2009 9:43 AM

> Ouch -- Jeffrey Friedl

C'mon man! It was a challenge! Where's *your* new Regular Expressions book? :)

Jeff Atwood on June 9, 2009 9:45 AM

I use Jan Goyvaerts' EditPad Pro and RegEx Buddy at work constantly. It is really amazing how much better/faster EditPad Pro is than every other text editor I have com across. Well worth the money (even if it pains you to pay money for a text editor).

Beau on June 9, 2009 9:58 AM

You know, sometimes I wonder, whether you're being paid to advertise these books.

AbdulSattar on June 9, 2009 10:06 AM

I too love regular expressions... The process of writing one, for me at least, is so involved and arcane, and in the end you get this tiny, nearly indecipherable sequence of characters which is so packed with raw power.

I feel like a freaking wizard every time I make one. I want to shout to my fiancée, "Look, woman, behold the magic I have created!"

Of course, she just rolls her eyes and goes back to whatever it was I had the gall to interrupt her from.

Asmor on June 9, 2009 10:24 AM

How much are Jan and Stephen paying you?

Roger on June 9, 2009 10:26 AM

Can Indians purchase e-books (and print them out) if they are purchased online? The Kindle has not arrived in India, AFAIK. While some books that the publishers think have demand make it to the market in Eastern Economy Editions which are sanely priced, many good books do not. If it costs $5 for a Starbucks coffee (maybe in a nice ambience) in the US, it costs INR 50 out here.
So if a book costs $25, it should roughly cost abt 250 here.
Some calculation of that sort - if you buy 1000 Regex books, it costs you an average monthly ordinary developer salary. Here the ordinary developer salary is INR 30,000. So I should be able to buy the Regex books at INR 30 apiece.
This is not accurate or correct. But let us say INR 150 per copy. Comes to $3. This is the disparity. Hence if the book has no EAstern Economy Edition, we have to buy it at $20 or whatever, online.
Tough on us to go straight way. Most people end up using torrents.
I suspect the rest of the world has similar reasons to make copies for cheap. This is not a programming problem, but it can have a solution which might come from programmers. Like we make a constantly updating, open-currency index based on livelihood expenses - bread, grains, water, power, etc, etc.

Alternatively, give me the book on bittorrent :-P

ConkCurrency on June 9, 2009 10:30 AM

@Asmor: Brilliant. :)

@Roger, et al: Seriously, I know we once all thought it was funny to accuse a blogger of getting a kickback any time they endorse something, but unless you have access to Mr. Atwood's financial records, chill out already. If you have read the book and can endorse/counter-endorse it, groovy, otherwise no one wants to hear it.

CynicalTyler on June 9, 2009 10:35 AM

An other way to keep regular expressions readible, is to use groups. The base2 library has the RegGrp-class for just that:

http://base2.googlecode.com/svn/doc/base2.html#/doc/!base2.RegGrp

Doeke Zanstra on June 9, 2009 10:39 AM

> Not sure why the Friedl book gets the cool wise Owl while Jan and
> Steve get a freakin' rat.

Shrew != rodent.

I am of two minds about your enthusiastic endorsement, Jeff. Good to know that there are additional learning resources for being able to create (and possibly even decipher) what looks like line noise. Unfortunately, however, better documentation will just encourage people to use more regular expressions. :-)

mike on June 9, 2009 11:03 AM

Ironic name though.

"Regular" expressions always struck me as particularly constipated code.

DevMan on June 9, 2009 11:15 AM

In portuguese (pt_BR), we have Aurelio Marinho Jargas's book "Expressões Regulares - Uma Abordagem Divertida". It uses the same principle: clear and concise expressions in every chapter, showing real world solutions: http://www.piazinho.com.br/
A little masterpiece in a language lacking good technical books.

Spark on June 9, 2009 11:51 AM

@CynicalTyler
If you looked at the link to amazon it has a tracking tag on it.

What he's doing with it I don't care, but there's definately a kickback here. Maybe he's donating it all to orphans. Orphans with diseases.

Matt Mousseau on June 9, 2009 11:55 AM

Yes! Reg Ex rocks. I'm going to have to pick this one up...

JoeMo on June 9, 2009 12:00 PM

Hmmm... your words almost match the words found here:

http://www.speedy-b.com/?p=25586

So we either need a snippet of regex for:

- Jeff nabbing speedy's words

- Speedy nabbing Jeff's words

- Or perhaps there's another explanation...

Michael on June 9, 2009 12:26 PM

I found the infallible logic of ConkCurrency irresistibly hilarious (not a good thing).

Jeff is going to get thousands of clicks on this one and a nice paycheck from amazon :) Congrats :)


Why wouldn't you be able to purchase an ebook in India from the site in US? You can most certainly get a PDF.

You can also find the same material online: regular expressions in all shapes and sizes.

securityhorror on June 9, 2009 12:30 PM

"Although Regular Expressions are really awesome, real men use (LA)LR parsers."

Sane men use something like ANTLR with LL(k) parsing but EBNF grammars.

Evan on June 9, 2009 12:35 PM

I wrote: > Or perhaps there's another explanation...

Well, it looks as though speedy has in linked to Jeff's site I see now (missed it 1st time around) I really wish these things were attributed more plainly...

Michael on June 9, 2009 12:35 PM

Isn't a musk shrew the most naturally sexy of all the creatures put on the front of these things? I mean, it's got musk right there in the name. Sexah.

Dylan Brams on June 9, 2009 12:39 PM

Regex is a hairy topic, the shrew fits in nicely.

Sami on June 9, 2009 12:48 PM

Who picks the covers for these books, that's what I want to know.

Kris on June 9, 2009 1:08 PM

If you are in India, just go to www.regular-expressions.info for free. It's probably 60% as good as the book for free. You will have no trouble learning it from that.

Also, a good (free with registration) testing program for .NET is Expresso.

PRMan on June 9, 2009 1:13 PM

Perl may not have invented regexes, but it's done more to advance the state of the art than anything else. Have you seen what Perl 6 is doing with them? Check out http://perlcabal.org/syn/S05.html for the full scoop. Prepare to have your mind blown.

Bruce K on June 9, 2009 1:30 PM

> I've never been a fan of the classic regular expression reference
> book, Friedl's Mastering Regular Expressions. I found it dry, a
> bit academic

[ laughter ]

Yup, that's Friedl's book. Academic. Reads like a tour through the classic techniques of regular expression; between the tour of the hierarchies of grammars and the detailed discussion of Brzozowski minimization, I practically got a nosebleed.

Hugo Root on June 10, 2009 2:21 AM

No doubt I'm in the minority here but...

Bought the PDF, read it, and while its alright, the constant references to Jan's software don't sit well with me somehow. Reads like a infomercial. No disrespect intended here honestly, just not my cup of tea.

I've found O'Reilly's book on * grep more practical. Has several real world examples, recipes section, etc. Plus grep is free without references to additional software I'd rather not purchase. All in all, Regular Expressions Cookbook is not bad, but not great. I feel Jeff could've better served his readership with some examples from the book to justify his praise of it too. But hey - that's life.

*Think about it... g/re/p

Tom on June 10, 2009 2:55 AM

There's often value in having both the "academic treatise" and the "getting things done" book - I'd suggest that those really interested in regex may get something out of both :)

DrewG on June 10, 2009 4:30 AM

"You know, sometimes I wonder, whether you're being paid to advertise these books." - AbdulSattar

If he was, there would be no need for ouches!

Daniel Earwicker on June 10, 2009 4:59 AM

"You know, sometimes I wonder, whether you're being paid to advertise these books."

Whilst I'm sure Jeff is above suspicion in this regard, I do wonder about the ethics of using referrals without full disclosure. There must be a conflict of interest when someone is earning a share of the profits of something they review.

Oh, and what have you got against shrews?

Steve W on June 10, 2009 6:18 AM

stick my book into your *** then!

Jeffrey Friedl on June 10, 2009 6:42 AM

Is there a recipe in the Cookbook for eliminating useless posts like, "First!"?

Craig Boland on June 10, 2009 8:57 AM

When I look at the URL address of the link to the book on amazon you posted, I see a 'tag=codinghorror-20'. What does that mean?

David on June 10, 2009 9:18 AM

Strongly recommended tool for regexing: Regex Coach (->google). with it, you can learn, validate and use regexes. a cool tool if i've ever seen one. plus, it's freeware.

bradbury on June 10, 2009 9:56 AM

Jeff is making money through amazon kickbacks.
If you buy the book using that link, Jeff earns a percentage on what you spend.

Hartmut on June 10, 2009 10:31 AM

@seth: "By the way, @DevMan: that's actually why the name is very good. It describes the academic properties of these expressions: RE (BRE or ERE)"

Except regexs in real languages rarely are regular. Once you have backreferences, you no longer have a regular expression.

(Alternatively, it's still a regular expression, by a different definition, and you just break the property you extol of it being properly descriptive.)

Evan on June 10, 2009 10:54 AM

>... I see a 'tag=codinghorror-20'. What does that mean?
That is an amazon referral link and he *might* get a couple of pennies if you buy it at that time. You will see similar looking tags on other sites as well. I don't know about Jeff's case, but another blog says it buys them a couple books/year.

>Is there a recipe in the Cookbook for eliminating useless posts like, "First!"?

There was a site I used to watch for the shear train-wreck-in-progress nature of the place: f*dcompany.com. They'd replace "first" with "boobies" and add random time to the timestamp of the post (like 12hrs or a couple days, so it ends up way down the thread).

Peter on June 10, 2009 11:21 AM

He gets far more than a couple of pennies -- he'd get over a dollar to three dollars per purchase, which can be very rewarding if such a popular blog convinced a lot of people to buy the book.

Getting a loyal following and then monetizing them from Amazon sales is one of the most lucrative tactics around.

Having said that, there is nothing wrong with Jeff doing that. If he likes the book and wants to speak nicely about it, and it wasn't the motivation behind pimping people to buy a book (personally I think about 99.999% of this field's books are trash and are unrecommendable. You're almost always better off with Google searches and experimentation), then he might as well benefit from it.

Dennis Forbes on June 10, 2009 1:03 PM

I'm alread a regex fan. I'll be getting this book. Thanks for the tip.

Philip on June 11, 2009 7:37 AM

It's always good to praise a book. But, if you comparatively praise a book without proper substantiation, then it's sounds like a sales effort.

Jeff, it takes a lot of time and effort to write a book. The authors strive hard to put together their knowledge in writing so that it is easy for other people to learn. It takes months of effort, for virtually no monetary return. Criticizing such an effort makes you look like a cheap f**ker.

britto on June 11, 2009 8:29 AM

ill try the book, i know regex, but not the advance regex(lookaheads and stuff), so maybe i will learn them this time.

barman on June 12, 2009 2:18 AM

Might enjoy David Seruyange's 'Nregex' - nline RegEx Evaluator and playground as referenced by Hanselminutes.

http://www.nregex.com/nregex/default.aspx

portagemonkey on June 12, 2009 5:55 AM

Jeff, I wasn't wondering what the $&!@( that was on the front cover. I was wondering what the /^\w+$/!

rcw on June 12, 2009 8:58 AM

Friedl's book is absolutely awesome. Really. I don't agree with the negative comments that seem to pop up all of a sudden now. Sounds like rather cheap criticism to me.

That said, I haven't read this new Regex Cookbook (yet). Hearing you say that it replaces Friedl's book as the go-to reference for regular expressions, makes me very curious, though.

Geert on June 14, 2009 3:26 AM

Friedl's book is absolutely awesome. Really. I don't agree with the negative comments that seem to pop up all of a sudden now. Sounds like rather cheap criticism to me.

That said, I haven't read this new Regex Cookbook (yet). Hearing you say that it replaces Friedl's book as the go-to reference for regular expressions, makes me very curious, though.

Geert on June 14, 2009 3:26 AM

With each passing article I find you more annoying :)

Bob on June 15, 2009 8:55 AM

I seriously learned how to craft and maintain regular expressions with Jeffrey's "Mastering Regular Expressions" book. I do think it is one of the most valuable books I've ever read!

I do love the cookbook style & format from O'Reilly, but would recommend "Mastering Regular Expressions" as the definite guide in understanding how to create/read regular expressions.

Rob on June 15, 2009 12:54 PM

I guess them's the breaks..

display on June 16, 2009 3:21 AM

If you think the world will come to an end if Jeff Atwood makes a buck or two from an Amazon.com affiliate link, you can always visit the book's official site at www.regexcookbook.com and give the affiliate percentage to the authors, or you can visit www.amazon.com directly and let Amazon keep the profit.

My own opinion is that if you discovered our book on Jeff's blog, then Jeff is more than welcome to get the 6% or 7% commission that Amazon pays. Writing a blog with useful content is a lot of work. The more his blog helps feed him his family, the more incentive he has to keep doing it.

It's a fallacy to think that bloggers can make money by recommending books they don't actually like just to get affiliate commissions. Those bloggers quickly find themselves without readers.

Jan Goyvaerts on June 16, 2009 10:56 AM

Great Book... Now can you use regex to eliminate the Tards that post First replies??? That would be an awesome use of Regex!

Mike on June 17, 2009 8:39 AM

Jan Goyvaerts writes: If you think the world will come to an end if Jeff Atwood makes a buck or two from an Amazon.com affiliate link, you can always visit the book's official site at www.regexcookbook.com and give the affiliate percentage to the authors, or you can visit www.amazon.com directly and let Amazon keep the profit.

Or one can simply click the banner of yours that slyly appeared (unethically in my mind) at the top of the O'rielly page for Mr. Friedl's *vastly superior* Mastering Regular Expressions. Why earn excellence when you can simply purchase banner impressions eh? You've have owls plastered over everything with that banner, as well as all things regex related at your own site - I dub it 'Owl Envy'.

Tom on June 18, 2009 7:12 AM

I've read both books and like them both, but MRE3 is a far better tutorial. (I too, pre-ordered Jan's new book sight unseen based on my love of EditPad Pro, RegexBuddy and PowerGrep. Jan is a software genius IMHO.) But if you want to MASTER regular expressions, you are going to need to spend quite a bit of TIME STUDYING the intricacies of just how the underlying engine really works in order to craft regexes that work REALLY well (i.e. matching what you want and not matching what you don't want and doing so QUICKLY). Friedl's MRE3 is the one to study if you want to truly become a regex GURU (the Slashdot review gave it 11 out of 10 and I agree 100%). "Regular Expressions Cookbook" is not the kind of book you read cover to cover (although the first two chapters are meant to be read that way). It is the book you go to if you are not a master and simply need a quick regex solution that is both accurate and efficient. (If you are a master, you can easily come up with your own custom-fit recipes!) Although it can be used as a tutorial, that is not its primary focus - However it EXCELS as a cookbook and as a regex reference.

And I disagree with those who say Friedl's book is dry. I found it quite entertaining, given the subject matter (and yes, there is even some humor in there!) On the other hand I found Jan's book to be dryer and more encyclopedic in its full coverage of all modern regex flavors across many different recipes. To its credit, the "Cookbook" covers the Javascript flavor (which is missing in MRE) but omits coverage of the recursive expressions found in the recent versions of PHP/PCRE (which is covered in MRE3).

Buy them both and make up your own mind. They are each very good at what they aim to do.

Jeff Roberson on June 27, 2009 1:02 PM

Why are there so many web frameworks? Because it's easier to think about parsing a string, and generating another string in response, then it is to learn the required structure of most of these frameworks. So people roll their own.

Oyunlar on July 8, 2009 12:11 PM

It's really a nice blog. I like it. It's really informative blog. Keep it up nice blogging.

nirenjan.raj on July 9, 2009 12:36 PM

As the Delphi R&D Manager, I have to add that Jan Goyvaerts is a Delphi developer and his excellent tools are all built using Delphi.

Nick

Nick Hodges on July 10, 2009 7:05 AM

Tom,

The RegexBuddy advertisement you're referring to is simply an ad that runs on Google's AdWords network using the keyword "regular expressions". If a web site uses Google's AdSense to display ads and Google determines that the site has content relevant to "regular expressions", then the RegexBuddy ad is likely to appear. Whether it does depends on a lot of factors.

There's nothing sly about it. Webmasters can easily block ads from www.regexbuddy.com or remove AdSense completely if they feel the ads are inappropriate. But I think most are happy to make an extra buck.

Jan Goyvaerts on July 12, 2009 11:46 AM

I just noticed that MonoDevelop 2.0 includes a "Regular Expression Toolkit" in the tools menu.

Screenshot:
http://files.getdropbox.com/u/119154/permalink/monodevelop-regex-toolkit.png

wcoenen on August 1, 2009 6:30 AM

ohh good..

videolar on August 13, 2009 11:13 AM

Thanks a lot Man..

youtube gir on August 31, 2009 1:46 PM

Keep it up nice blogging

oyun oyna on September 6, 2009 4:19 AM

More comments»

The comments to this entry are closed.