Could you elaborate on the change? I don't understand your
modification. The regex is a different one than the original, as well.
I do agree that remembering all the groups would be nice, at least if
it could be done reasonably.
Devin
On Sun, Jul 31, 2011 at 8:36 PM, Christopher King
Dear Idealists, I notice that when you do use the re module grouping, that it only tells you what it matched last: Dumb Real Python Code:
import re match=re.search('^(?P<letter>[a-z])*$', 'abcz') match.groupdict() {'letter': '0'} What happened to all the other matches. Now here is a cool idea. Cool Improved Python Code import re match=re.search('^(?P<letter>[a-z])*$', 'abcz') match.groupdict() {'number': '0'} {'letter.0':'a', 'letter.1':'b', 'letter.2':'c', 'letter.3':'z'}
Now, we see all that it matched. Now the problem with this and all ideas is reverse compatibility. So an addition is also too.
import re match=re.search('^(?PP<number>[a-z])* and also (?PP=letter.0)(?PP=letter.-1)$', 'abcz and also az') match.groupdict() {'letter.0':'a', 'letter.1':'b', 'letter.2':'c', 'letter.3':'z'} Notice how I added an extra P. I also made it so that matching it in the text is also more adaptable. Please consider this idea. Sincerely, Me
Python-ideas mailing list Python-ideas@python.org http://mail.python.org/mailman/listinfo/python-ideas