Ask HN: Do I need a regex book?

3 points by solipsist ↗ HN
I'm starting to learn ROR and have noticed that regular expressions show up quite often. I'd like to get a solid understanding of them, but no online tutorial seems to be sufficient.

I've seen that the books like Mastering Regular Expressions and Regular Expressions Cookbook have great reviews on Amazon, but I'm wondering if it would be overkill to get a full book on something that I would only be using every so often.

I've also considered getting a reference book on regex, but those seem to offer no introduction/explanations whatsoever (which I need).

Is it worth it for me to read up a lot on regex?

6 comments

[ 3.6 ms ] story [ 18.7 ms ] thread
The best reference materials for regular expressions are available for free on all operating systems that have Perl installed: `perldoc perlretut` and `perldoc perlre`, in that order.

EDIT: ...in a terminal window.

Yes. Read Mastering Regular Expressions.
Regexes are a handy tool to know regardless of the language. And something I think is worth learning.

Mastering Regular Expressions is a good book to read as Mr. Friedl does a good (great?) job of explaining the pluses and minuses of regular expressions in a readable manner.

If all you want is how to use regular expressions then there are plenty of man pages and internet documents which provide examples that you can learn from without reading Mastering Regular Expressions.

You might look at the Ruby documentation to see how Ruby does things. And a quick search using Ruby regular expression provided this link: http://rubular.com/ which is a utility to test regexes. There are several other links immediately following this one which appear to be tutorial or information for what you are looking for.

1. You mention RoR, so I assume you are not aiming to understand the abstract computer science notion, but the practical thing as to what regular expression libraries (ruby's in particular) understand.

2. You do not mention which online tutorials you found insufficient. That makes it hard to recommend things. For example do you know about http://www.regular-expressions.info?

3. Have you played with regular expressions interactively? That could be through the command line, or via http://rubular.com/ (there are tons of such tools online, some better, but this one is for ruby)

As to your last question: whether it is worth for you? That depends on way too many unknowns for me to answer.