On Thu, Sep 16, 2010 at 01:31:09PM +0200, Peter Otten wrote:
> Michael Powe wrote:
 
> > The re module includes the option to comment a regular expression with
> > the syntax (?#comment).  e.g.

> > Is there a mechanism for extracting these values from the match, in
> > the way that group names are extracted?

> > I don't see one.
 
> You could write a regular expression to extract them ;)

;-)
 
> > The point would be that in my processing of the match, I could
> > implement the comments as identifiers for the matched value.
> 
> But that's what the names are for, e. g.:
> 
> >>> re.compile(r'(.*) (?P<parameter>WT.dl)=(?P<value>[^&]+).*').search(
> " WTxdl=yadda&ignored").groupdict()
> {'parameter': 'WTxdl', 'value': 'yadda'}

That's right, I forgot about the dictionary.  Thanks!

mp

-- 
Michael Powe            mich...@trollope.org            Naugatuck CT USA
"No provision in our Constitution ought to be dearer to man than that
which protects the rights of conscience against the enterprises of the
civil authority." -- Thomas Jefferson to New London Methodists,
1809. ME 16:332

Attachment: pgpH7zLFLwttx.pgp
Description: PGP signature

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to