[issue23318] (compiled RegEx).split gives unexpected results if () in pattern

2015-01-25 Thread Dave Notman
New submission from Dave Notman: # Python 3.3.1 (default, Sep 25 2013, 19:30:50) # Linux 3.8.0-35-generic #50-Ubuntu SMP Tue Dec 3 01:25:33 UTC 2013 i686 i686 i686 GNU/Linux import re splitter = re.compile( r'(\s*[+/;,]\s*)|(\s+and\s+)' ) ll = splitter.split( 'Dave Sam, Jane and Zoe' )

[issue23318] (compiled RegEx).split gives unexpected results if () in pattern

2015-01-25 Thread SilentGhost
SilentGhost added the comment: Looks like it works exactly as the docs[1] describe: re.split(r'\s*[+/;,]\s*|\s+and\s+', string) ['Dave', 'Sam', 'Jane', 'Zoe'] You're using capturing groups (parentheses) in your original regex which returns separators as part of a match. [1]