in reply to Re: Re: Ovid, Long Live .*? (dot star question-mark)
in thread Ovid, Long Live .*? (dot star question-mark)

I found out why captuuring them does not activate the optimisation. It has to do with the regex tree. A regex like /.*?foo/ becomes:
1 MINMOD(2) 2 STAR(4) 3 REG_ANY(0) 4 EXACT <foo>(6) 6 END
whereas the tree for /(.*?)foo/ is:
1 OPEN1(3) 3 MINMOD(4) 4 STAR(6) 5 REG_ANY(0) 6 CLOSE1(8) 8 EXACT <foo>(10) 10 END
In the non-capturing version, the node directly after STAR is EXACT. In the capturing version, the node is CLOSE. I patched regexec.c to allow for a CLOSE in between the two.

_____________________________________________________
Jeff[japhy]Pinyan: Perl, regex, and perl hacker.
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;