[issue17668] re.split loses characters matching ungrouped parts of a pattern

Matthew Barnett report at bugs.python.org
Mon Apr 8 20:55:39 CEST 2013


Matthew Barnett added the comment:

It's not a bug.

The documentation says """Split string by the occurrences of pattern. If capturing parentheses are used in pattern, then the text of all groups in the pattern are also returned as part of the resulting list."""

You're splitting on r'^>(.*)$', but not capturing the '>', therefore it's excluded.

If you want the '>' included, then put it inside the capture group too.

----------

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


More information about the Python-bugs-list mailing list