[issue1519638] Unmatched Group issue - workaround

Matthew Barnett report at bugs.python.org
Fri Mar 16 01:59:59 CET 2012


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

The replacement can be a callable, so you could do this:

re.sub(r'(?:\((?:(\d+)|.*?)\)\s*)+$', lambda m: m.group(1) or '', 'avatar (special edition)')

----------

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


More information about the Python-bugs-list mailing list