Regular Expressions for Regular Programmers

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.

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…

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?

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

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).

using JeffHasBeenHere = System.Text.RegularExpressions;

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

“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.

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

@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”.

I’ve never had the need to use regular expressions

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.

You should just code your directive like this:

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

Hehe…

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

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

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.

My first post here, been lurking for months!

Just posting to say: bought :slight_smile:

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

“Also, if you’re wondering what the $&!@ …”

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

“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 :slight_smile: - see “Two Types of Technical Books” (http://www.hamagudi.com/2009/06/two-types-of-technical-books.html)