scanf style parsing

Ralph Corderoy ralph at inputplus.demon.co.uk
Mon Oct 1 06:23:16 EDT 2001


Hi,

> > An easy, sure fire way for any programmer to learn regex concepts
> > is to read Kernighan and Plauger's _Software Tools_ where, amongst
> > many other interesting topics, they implement a regex pattern
> > matcher and preceed to use it in their versions of grep, ed, etc.
> 
> The problem is that this gives a narrow view of regexes and doesn't
> show the full power available in complex regex languages in
> Perl/Python.

But that's part of its appeal.  By just sticking with concatenation,
repetition, and alternation you can see through the regex syntax to the
implementation and the matching engine.  Everything from then on is
either syntax enhancements, e.g. r+ == rr*, or stuff that you can
easily learn because you've a good grounding.

> Much better is _Mastering Regular Expressions_ by Jeffrey Friedl,
> though it badly needs freshening.

I've read that and I think it goes too deep too soon and takes too many
pages to do it.  It is also cluttered in having to state all the
exceptions at every turn, e.g. `but not in egrep'.  _Software Tools_
gives sufficient grounding to a programmer in a chapter.

Also, like you say, a large part of _Mastering Regular Expressions_ is
out of date since Python and Perl have moved on.  Given how much hassle
JF said it was to right in the first place I wouldn't expect to see him
queing up to right the 2nd Ed. :-)

Cheers,


Ralph.




More information about the Python-list mailing list