All the Perl that's Practical to Extract and Report

Navigation

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
Without JavaScript enabled, you might want to
use the classic discussion system instead. If you login, you can remember this preference.

It's also one of the slower engines, and at least in Ruby 1.6 its \G doesn't prohibit regex bump-along (it's "start of current match" rather than "end of last match"), which makes relatively useless to write complex parsers with.

Of course! If you need recursive regexen, fast but broken is obviously useless. Just don't disregard that you can talk about working vs broken only with regard to recursion. For me, Ruby's engine is similarly useless because of its \G behaviour as Perl's engine is for you because of non-reentrancy.

When trying to match abcde with/\Gx?/g, the first match is successful, because no x is found but the question mark allows zero characters to be consumed. This match ends after zero characters into the string at start-of-string. In order to avoid infinite loops on a zero-length matches, the engine then retries the match one position down the string.

In Perl, \G means end-of-last-match, and since end-of-last-match was at start-of-string, \G can't possibly match at one character into the string: