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

regex will not match twice at the same position, it will advance by one on the second attempt.

It's somewhere in the docs, but I can't find it just now.

  • Comment on Re: strange behaviour: continue with \G and /gc and look forward

Replies are listed 'Best First'.
Re^2: strange behaviour: continue with \G and /gc and look forward
by ikegami (Patriarch) on Dec 14, 2019 at 17:33 UTC

    It can match at the same position twice.

    say "[$-[0], $+[0])" while "aaaaa" =~ /a*?/g;
    [0, 0) [0, 1) [1, 1) [1, 2) [2, 2) [2, 3) [3, 3) [3, 4) [4, 4) [4, 5) [5, 5)

      I should have said "regex will not ZERO LENGTH match twice at the same position".