regexp compilation error

Ovidiu Deac ovidiudeac at gmail.com
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/re.py", line 190, in compile
    return _compile(pattern, flags)
  File "/usr/lib/python2.6/re.py", line 245, in _compile
    raise error, v # invalid expression
sre_constants.error: nothing to repeat

Is this a bug or a feature?

Thanks,
Ovidiu



More information about the Python-list mailing list