BPO | [15537](https://bugs.python.org/issue15537) --- | :--- Nosy | @ezio-melotti, @dabrahams, @serhiy-storchaka Superseder | bpo-11957: re.sub confusion between count and flags args *Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.* Show more details GitHub fields: ```python assignee = None closed_at = created_at = labels = ['expert-regex', 'type-bug'] title = 'MULTILINE confuses re.split' updated_at = user = 'https://github.com/dabrahams' ``` bugs.python.org fields: ```python activity = actor = 'vstinner' assignee = 'none' closed = True closed_date = closer = 'ezio.melotti' components = ['Regular Expressions'] creation = creator = 'dabrahams' dependencies = [] files = [] hgrepos = [] issue_num = 15537 keywords = [] message_count = 5.0 messages = ['167228', '167240', '167243', '167282', '167283'] nosy_count = 4.0 nosy_names = ['ezio.melotti', 'mrabarnett', 'dabrahams', 'serhiy.storchaka'] pr_nums = [] priority = 'normal' resolution = 'duplicate' stage = 'resolved' status = 'closed' superseder = '11957' type = 'behavior' url = 'https://bugs.python.org/issue15537' versions = ['Python 2.7'] ```
Activity
dabrahams commentedon Aug 2, 2012
compare the output of
$ python -c "open('/tmp/tst','w').write(100*'x\n');import re;print len(re.split('\n(?=x)', open('/tmp/tst').read()))" 100with
$ python -c "open('/tmp/tst','w').write(100*'x\n');import re;print len(re.split('\n(?=x)', open('/tmp/tst').read(), re.MULTILINE))" 9serhiy-storchaka commentedon Aug 2, 2012
mrabarnett commentedon Aug 2, 2012
There are actually 2 issues here:
The third argument is 'maxsplit', the fourth is 'flags'.
It never splits on a zero-width match. See bpo-3262.
ezio-melotti commentedon Aug 3, 2012
See also bpo-11957.
dabrahams commentedon Aug 3, 2012
Dang! Thanks, and sorry for wasting everyone's time on this.