[issue7132] Regexp: capturing groups in repetitions

Matthew Barnett report at bugs.python.org
Thu Nov 18 19:37:33 CET 2010


Matthew Barnett <python at mrabarnett.plus.com> added the comment:

Earlier this week I discovered that .Net supports repeated capture and its API suggested a much cleaner approach than what Perl offered, so I'll be adding it to the regex module at:

    http://pypi.python.org/pypi/regex

The new methods will follow the example of .group() & co.

Given a match object m, m.group(i) returns the last match of group i (or None if there's no match), so I'll be adding m.captures(i) to return a tuple of the captures (an empty tuple if there's no match). I'll also be adding m.starts(i), m.ends(i) and m.spans(i).

The issue for this work is #2636.

Units tests are welcome.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7132>
_______________________________________


More information about the Python-bugs-list mailing list