Finally, we can use something like
This uses \ escaped slashes in the replacement part, as well as expanded
variables inside the string manipulation, both in the pattern as well as
in the replacement. You can add a \ infront of every character, all it
does is skipping the \ and treating the next character as a non-special
character, so \X is an 'X', \\ is '\', \$ is a '$' (to not start a
variable expansion and be able to put a verbatim variable name into the
output), \) is ')' and so on.