How do I get to *all* of the groups of an re search?
Kyler Laird
Kyler at news.Lairds.org
Thu Jan 9 16:25:57 EST 2003
More information about the Python-list mailing list
Thu Jan 9 16:25:57 EST 2003
- Previous message (by thread): How do I get to *all* of the groups of an re search?
- Next message (by thread): How do I get to *all* of the groups of an re search?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
http://www.python.org/doc/current/lib/re-syntax.html (...) Matches whatever regular expression is inside the parentheses, and indicates the start and end of a group; the contents of a group can be retrieved after a match has been performed, [...] Sounds good, so I tried it. import re text = 'foo foo1 foo2 bar bar1 bar2 bar3' test_re = re.compile('([a-z]+)( \\1[0-9]+)+') print test_re.findall(text) I expected the matches to be something like [('foo', [' foo1', ' foo2']), ('bar', [' bar1', ' bar2', ' bar3'])] but it's just this. [('foo', ' foo2'), ('bar', ' bar3')] How do I get to the other groups that were matched? (Is this an FAQ? I don't know where to start looking.) Thank you. --kyler
- Previous message (by thread): How do I get to *all* of the groups of an re search?
- Next message (by thread): How do I get to *all* of the groups of an re search?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list