[Python-Dev] Re: re recursion limit

A.M. Kuchling amk@amk.ca
Wed, 26 Feb 2003 17:19:51 -0500


Gary Herron wrote:
 >I wrote:
>>Maybe just fixing the problem for .* will be sufficient.

Sorry, brain error on my part: I meant fixing it for .*?.
.* doesn't have a problem because the engine can chew up as many matches 
for '.' as possible, try the rest of the pattern, and then back up
for '.'.

In other words: .* requires stack space proportional to the size of the 
regex pattern, which is OK; .*?, as currently implemented, requires
stack space proportional to the size of *the string being matched*, 
which is what causes the problem.

--amk                                                    (www.amk.ca)
MIRANDA: Your tale, sir, would cure deafness.
       -- _The Tempest_, I, ii