This is due to Regexp replace syntax and literal strings.
In literal strings, you need two \ to produce one \ character (a single is the start of an escape character like \t, \n, ...).
And in Regexp replacement strings, you need to escape the \ (a single one is the beginning of a special replacement sequence like \1,&,...).
So that makes 4 \ for one produced in literal replacement strings:
((If replacement is a String it will be substituted for
the matched text. It may contain back-references to the pattern's capture
groups of the form \\d, where d is a group number, or \\k, where n is
a group name. If it is a double-quoted string, both back-references must be
preceded by an additional backslash.))
((If replacement is a String it will be substituted for
the matched text. It may contain back-references to the pattern's capture
groups of the form \\d, where d is a group number, or \\k, where n is
a group name. If it is a double-quoted string, both back-references must be
preceded by an additional backslash.))