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

Mike Coleman mkc at mathdogs.com
Sat Aug 7 19:33:05 CEST 2004


Michael Hudson <mwh at python.net> writes:
> Well, I thought *someone* should say *something*, just to stop the
> proto-pep being lost.  Have you sent it to the PEP editor yet?  I
> think it's ready enough.

I'm happy you did--I was just joking.  Yes, I've sent it to the PEP guys, but
no response yet.

> The reason that I only said "mildly useful" was because I didn't think
> "OMG!  I would so have liked to use this yesterday" or anything like
> that...

Sure, I understand.  I run into a lot of these cases at work, where the domain
is bioinformatics (lots of pattern matching and parsing of ad hoc file formats).

> It depends a bit on whether it can be implemented as an addition in a
> non-painful way, or whether editing the sre code makes it very much
> easier.  I don't know the answer, mind.

I'm thinking (hoping) that it could piggyback on the current re.match
implementation in a fairly clean way.  The algorithm is the same--we just have
to "notice" a few more things while we're carrying it out and arrange to
return those noticed things at the end.

> I think you could make a case for raising an exception; the point of
> structmatch is to extract information, whereas at least sometimes you
> call re.match just to see if the data matches the pattern.

Yeah, I'm leaning in this direction, too.

Mike



More information about the Python-Dev mailing list