in reply to strange behaviour: continue with \G and /gc and look forward

The higher-level loops preserve an additional state between ite +rations: whether the last match was zero-length. To break the loop, the following match after a zero-length match is prohibited to have + a length of zero. This prohibition interacts with backtracking ( +see "Backtracking"), and so the second best match is chosen if the +best match is of zero length.

Replies are listed 'Best First'.
Re^2: strange behaviour: continue with \G and /gc and look forward
by leszekdubiel (Scribe) on Dec 13, 2019 at 21:35 UTC

    Ok thank you very much. Community around perl is great. Actually I've been programming perl for a long time and this bite me for the first time.

    Here is the link:

    https://perldoc.perl.org/perlre.html#Backtracking

    search for phrase " higher-level loops "