If I write this in Scala:
System.err println "Done".replaceAll(".*$", "$0xyz")
Then the output is unexpectedly not Donexyz
but Donexyzxyz
.
I have some idea of what's going on – Done
is being turned into Donexyz
, and then a second replacement is happening, matching against Donexyz
and turning it into Donexyzxyz
. (Using replaceFirst
produces Donexyz
, confirming this.) But that doesn't explain everything -- in particular I don't know why we don't get
Done -> Donexyz -> Donexyzxyz -> Donexyzxyzxyz -> ...
Any illumination would be appreciated.