Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo


Commit [163740] legacy-trunk Maximize Restore History

Applied patch #725106, by Greg Chapman, fixing capturing groups

within repeats of alternatives. The only change to the original
patch was to convert the tests to the new test_re.py file.

This patch fixes cases like:

>>> re.match('((a)|b)*', 'abc').groups()
('b', '')

Which is wrong (it's impossible to match the empty string),
and incompatible with other regex systems, like the following
examples show:

% perl -e '"abc" =~ /^((a)|b)*/; print "$1 $2\n";'
b a

% echo "abc" | sed -r -e "s/^((a)|b)*/\1 \2|/"
b a|c

Gustavo Niemeyer Gustavo Niemeyer 2003-04-27

changed Lib/test/test_re.py
changed Modules/_sre.c
Lib/test/test_re.py Diff Switch to side-by-side view
Modules/_sre.c Diff Switch to side-by-side view