in reply to Re: Bug or feature? s/// and the g option
in thread Bug or feature? s/// and the g option

Agreed. I can't readily think of any time that it would be particularly useful to say "do a bunch of replacements, then tell me what the last thing replaced was" - you'd normally want to either see all the replacements (by using $1 inside a loop on the regex) or none of them (by not using $1 at all).

While the OP's code brings out an interesting quirk, I think I'd call it undefined behaviour rather than a bug or a feature.

  • Comment on Re^2: Bug or feature? s/// and the g option