First real post in a while…just to note that I’ve been reading the very good Mastering Regular Expressions (O’Reilly) by Jeffrey E. F. Friedl.
Despite covering a hard to understand topic the text isn’t very dry at all filled with lots of real world type examples to ease the reader into understanding the more complicated regular expressions (regexs).
I was going to include an example of a regex that still gives me the creeps but is now a lot easier to figure out whats going on. But it appears I can’t use a backslash in my posts so I can’t put the regex here. Guess I’ll have to go digging to find out what causes that 😦
Just when I think I get out of having to mess with the source code too…
Anyway, if you think you’ll be using Regexs anytime soon and you don’t know them very well or if you want to know how some regex engines work, pick up this book. Unfortunately it isn’t availabe on Safari and probably won’t be because of the heavy use of what I guess you’d call typographical annotations. You can always buy through Amazon though.
Update: Nish asked a rather important question, whether the regular expressions in the book follow .NET’s syntax or some other syntax. It actually does both. The book is more about understanding regular expressions in general, the syntax being nothing more than expressing what you want. So far in the book I’ve seen egrep, Perl, and Java examples used. That’s not to say .NET isn’t covered, but most of the syntax is the same it is learning the nuances each tool have and how to use the tools features that need covering.
The table of contents for the book is layed out in three parts of three chapters each. Here is how the author lays it out in the preface, any spelling errors or inconsistencies in the passage below are my own with the preface being in the first few pages I had to bookmark it and keep flipping to the page to read what is said.
- The Introduction
- Chapter 1 – Introduces the concept of regular expressions
- Chapter 2 – Takes a look at text processing with Regular Expressions
- Chapter 3 – provides an overview of features and utilities, plus a bit of history
- The Details
- Chapter 4 – Explains the details of how regular expressions work
- Chapter 5 – works through examples, using the knowledge from chapter 4
- Chapter 6 – discusses efficiency in detail
- Tool-Specific Information
- Chapter 7 – covers Perl regular expressions in detail
- Chapter 8 – looks at regular expression packages for Java
- Chapter 9 – looks at .NET’s language-neutral regular expression package.
As you can see from the list of chapters, .NET gets it’s own chapter to deal with its specific issues/features and there are plenty of tables in chapter 3 which compares different regex features with the different tools listed in the book.