[Python-Dev] Some questions about maintenance of the regular expression code.
Gary Herron
gherron@islandtraining.com
Wed, 26 Feb 2003 02:58:43 -0800
On Wednesday 26 February 2003 01:08 am, M.-A. Lemburg wrote:
> Gary Herron wrote:
> > The first glance at the regular expression bug list and the _sre.c
> > code results in the observation that several of the bugs are related
> > to running over the recursion limit. The problem comes from using a
> > pattern containing ".*?" in a situation where it is expected to match
> > many thousands of characters. Each character matched by ".*?" causes
> > one level or recursion, quickly overflowing the recursion limit.
>
> Wouldn't it be possible for the RE compiler to issue a warning in
> case these kind of patterns are used ? This would be much more helpful
> than trying to work-around the user problem.
I think not. It's not the pattern that's the problem. A pattern
containing ".*?" is perfectly legitimate and useful. The problem
arises when the pattern is used on a string which has thousands of
characters which match. By that point the RE compiler is right out of
the picture.
Gary Herron