[Python-ideas] Re module repeat

Christopher King g.nius.ck at gmail.com
Mon Aug 1 02:56:44 CEST 2011


On Sun, Jul 31, 2011 at 8:41 PM, Devin Jeanpierre <jeanpierreda at gmail.com>wrote:

> Could you elaborate on the change? I don't understand your
> modification. The regex is a different one than the original, as well.
>
What do you mean by elaborate on the change. You mean explain. I guess I
could do it in more detail. What would happen is if you do something like.

match=re.search('^(?*PP*<tag>[a-z])*$', 'abc')
Then the match.groupdict() would return
{'tag.0':'a', 'tag.1':'b', 'tag.2':'c', 'tag.-1':'c', 'tag.-2':'b',
'tag.-3':'a'}
notice the PP. This means that it will save all the times it matches. It
does this by adding a decimal after the tag to show the index. It also
supports negative indexing in case you want the last time it matched. All
these can be used with the old (?P=tag.-2) with it. Also, are there any
forbidden characters in a tag. That would be good to add so it won't mess
with current tags.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20110731/72c0bfb1/attachment.html>


More information about the Python-ideas mailing list