Issue 17184: re.VERBOSE doesn't respect whitespace in '( ?P...)' (original) (raw)

Python 2.7.3

Ubuntu 12.04

import re pattern = r"( ?P.*)" regex = re.compile(pattern, re.VERBOSE)

The above raises an exception in re.compile():

Traceback (most recent call last): File "./try.py", line 6, in regex = re.compile(pattern, re.VERBOSE) File "/home/roy/env/python/lib/python2.7/re.py", line 190, in compile return _compile(pattern, flags) File "/home/roy/env/python/lib/python2.7/re.py", line 242, in _compile raise error, v # invalid expression sre_constants.error: nothing to repeat

The problem appears to be that re.VERBOSE isn't ignoring the space after the "(".

Maybe this is a duplicate of ?