re module - error with non-greedy matches

Darrell dgallion1 at
Fri Jan 11 12:57:23 EST 2002

non-greedy can fail as you've seen, when using a large buffer.

>>> import pre, re
>>> buf='x'+'y'*10000
>>> buf='x'+'y'*100000
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "c:\python22\lib\", line 137, in search
    return _compile(pattern, flags).search(string)
RuntimeError: maximum recursion limit exceeded

pre is the older engine and sre is the new one. has this:
     engine = "sre"
   # engine = "pre"

sre is faster in many cases.
There is a fix in the works for sre, but it won't be out for a while.
(I can't find the note about that)


Derek Thomson <derekt at> wrote in message news:<3C3D381F.2030907 at>...
> I'm sure this works, but I really need to know that Python regexes 
> aren't broken before I can seriously use Python for all my scripting 
> needs.

More information about the Python-list mailing list