in reply to Re: /g option not making s// find all matches
in thread /g option not making s// find all matches

But since I have forced that position at -1

Which only works because input wasn't chomped, right? I wonder if someone misreads it as "which makes \G match nowhere". While, assigning negative values to pos counts leftward from the end (similar to parameter of substr, or negative array subscript, etc.). Surprise or not, this pos behavior isn't documented (nor silent clumping if value is out of bounds).

Replies are listed 'Best First'.
Re^3: /g option not making s// find all matches
by Eily (Monsignor) on May 30, 2018 at 08:00 UTC

    I wonder if someone misreads it as "which makes \G match nowhere"
    Well I miswrote it as that, I didn't know about the negative value of pos. pos = length will behave better in that case.