> :Anyway, Snobol has a nice heuristic to prevent infinite recursion in
> :cases like this, but I'm not sure it's applicable to the way the Perl
> :regex engine works.  I will think about it.
> 
> It is probably worth adding the heuristic above: anytime you recurse
> into the same re at the same position, there is an infinite loop.


That is basically it, except that in snobol it is inside out:  Each
recursively interpolated pattern is assumed to match a string of at
least length 1, and if the remaining part of the target string isn't
sufficiently long to match the rest of the pattern after recursion,
then the recursion is skipped.

Reply via email to