a regular expression question
Alex Martelli
aleax at aleax.it
Sun Mar 23 06:03:04 EST 2003
Luke wrote:
> Thanks, everyone. This was my first real encounter with re's. I need
> to find a better tutorial than the api info for the re package. I
If you want to become a RE guru, I recommend Friedl's "Mastering Regular
Expressions" (O'Reilly) -- not specifically about Python, but for RE's
themselves (as opposed to, how you program with them, in detail) there's
over 90% overlap between the "Perl" stuff Friedl covers, and Python.
In the Nutshell I devote 13 pages to RE's, mentioning some common idioms
and typical usage as well as covering the essentials of RE objects, but
that's really just the beginning of a long and VERY complicated story.
> will heed your advice and examine parsing libraries--didn't know they
> existed. Guess you really do get the kitchen sink with Python. :)
Oh yes -- I find myself using RE's about 100 times less than I was
using them back when I programmed in Perl, thanks on one side to the
useful built-in methods of string objects, on the other to higher
level library modules and extensions. Personally, the features
that do occasionally lead me to use RE's in Python are: convenient
case-insensitive matching; word-boundaries and word-characters
matching; ability to look for "any one of these N" for large N
thanks to the | alternation; in roughly decreasing order of
importance to stuff I typically find myself programming.
Alex
More information about the Python-list
mailing list