[Python-Dev] Re: pre-PEP [corrected]: Complete, Structured Regular Expression Group Matching

Erik Heneryd erik at heneryd.com
Tue Aug 10 15:00:50 CEST 2004


Fredrik Lundh wrote:
> a regular expression defines a set of strings, and the RE engine is designed to
> tell you if a string you have is a member of this set.  the engine's not a parser,

Well, as you know (and point out now and then), regexes aren't regular 
expressions in the CS sense.  And most people don't use em just to see 
if a string matches or not, but to see what parts matches waht.


> you're probably better off using the scanner mechanism:
> 
>     http://effbot.org/zone/xml-scanner.htm
> 
> or the sre.Scanner class (see the source code).  the scanner concept could
> need some documentation, and it would be nice to be able to switch patterns
> during parsing.  (time for a scanner PEP, anyone?)

I'd love to see scanners as an official part of the stdlib.  Isn't this 
just a matter of documentation?


Erik



More information about the Python-Dev mailing list