Le 14/12/2011 12:34, Vlastimil Brom a écrit :

"If a group is contained in a part of the pattern that matched
multiple times, the last match is returned."


I missed this point, your answer matches my question ;) thanks.


If you need to work with the content captured in the repeated group,
you may check the new regex implementation:
http://pypi.python.org/pypi/regex

Which has a special "captures" method of the match object for this
(beyond many other improvements):

import regex
m=regex.match('(Spam\d)+', 'Spam4Spam2Spam7Spam8')
m.captures(1)
['Spam4', 'Spam2', 'Spam7', 'Spam8']




Thanks for the reference and the example. I didn't know of this reimplementation, hoping it offers the Aho-Corasick algorithm allowing multiple keys search.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to