On Tue, Sep 07, 1999 at 07:34:38PM -0700, horos wrote: > > $brackets = qr{ > > { > > (?: > > (?> [^{}]*) | > > (?p{ $qr }) > > )* > > } > > }x; > : I do not follow this \G stuff. Where do you want to put it? > > Well, take the above regular expression. If there was a 'no backtracking' > operator, ??? There is 'no backtracking' operator, and you were using it. > you could match the following relatively quickly: > > "{this{ fails { very } slowly } without no backtrack op" =~ m"\G$brackets"; It is slow only because you asked it to be slow. It becomes twice as quick if you use (?> [^{}]+ ) instead of (?> [^{}]* ). It becomes six times as quick if you use your idea of $brackets = qr{ { (?: (?> [^{}]+ | (?p{ $qr }) ) )* } }x; [ I will investigate why one cannot drop these (?:). ] And probably you want m{\G(?p{ $brackets })}, which would avoid recompile of the REx. > Come to think of it, perhaps 'all or nothing' is a better term for the operator > - ie, if something fails to match, the engine rewinds all the way back > to the beginning, bumps up its position by 1 from the beginning point > and then starts again. Why this cannot be implemented by nested (?>) ? > So matching the above without the \G modifier would look like: > > tries '{.... (goes to end without success) > tries 't' (fails immediately) > tries 'h' (fails immediately) > tries 'i' (fails immediately) > tries 's' (fails immediately) > tries '{........ slowly } (succeeds.) Why do you think it is not doing it like this? Ilya