regexp compilation error

Ovidiu Deac ovidiudeac at
Fri Sep 30 11:10:48 CEST 2011

I have the following regexp which fails to compile. Can somebody explain why?

>>> re.compile(r"""^(?: [^y]* )*""", re.X)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.6/", line 190, in compile
    return _compile(pattern, flags)
  File "/usr/lib/python2.6/", line 245, in _compile
    raise error, v # invalid expression
sre_constants.error: nothing to repeat

Is this a bug or a feature?


More information about the Python-list mailing list