I don't think you actually need to escape the $ in the replacement expression here, because it's not followed by any other characters that would cause it to be treated as a metacharacter. (Plus it looks confusing :)) That said, if you feel that it's safer to escape it, it would be worth adding a comment explaining it.