I would also recommend Jeffrey Friedl's Mastering Regular Expressions book. I haven't read all those pods to the end yet so perhaps they cover all that's needed, but I can say his book helped me a great deal and touches specifically on some of the issues here (assuming you can't be convinced to use a module). For instance, I didn't properly understand how to match across newlines (or, sadly, even that newline is one of the things \s matches -- yikes) or what the /m and /s (and /ms) qualifiers do exactly until I read his book. The information was probably there in the perl pods but my eye must have glazed over it or struggled with the wording.
It also deals with how to match within quotes (and how to do so efficiently), to the point where Damian Conway's Perl 6 Exegesis 5 document even refers to a certain kind of regex as being "Friedl style".
If the latest edition is too long for you, the one I read (recently) was the 1st edition, and I can say that it's still valuable, even if it does leave out some newer Perl regex features. Just in case, I read parts of the chapters on dfas and nfas in a newer edition from the library and I think perhaps the coverage there was flushed out and improved some (have to say the car analogy is the single thing I dislike about the book -- maybe I'd be less bothered if it was a bicycle analogy, I dunno), but the bulk of the size increase seemed to come from covering more regex flavours from more languages (ones that I don't personally care about as much as the ones in the 1st edition). Someone correct me if this is a poor impression to put out into the world.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.