It's a pretty minor difference, but Henry's version does avoid the (typically small) overhead of capturing an extra group we don't really need. Group 0 (the whole regex) is
always captured. Additional capturing groups cost extra - if only slightly.
Regarding earlier posts: carefully following the documentation leads to this quote from Matcher.replaceAll():
Note that backslashes (\) and dollar signs ($) in the replacement string may cause the results to be different than if it were being treated as a literal replacement string. Dollar signs may be treated as references to captured subsequences as described above, and backslashes are used to escape literal characters in the replacement string.
This is almost useful documentation, but for some reason the author decided to neuter it by repeated and totally unnecessary use of "may". Dollar signs (if followed by numbers)
will be treated as references to captured subsequences. Too bad they didn't actually get around to
saying that. :roll: Siegfried's confusion on this point is understandable.