Replacing a substring with itself has no effect and usually indicates a mistake, such as misspelling a backslash escape.

Examine the string replacement to find and correct any typos.

The following code snippet attempts to backslash-escape all double quotes in raw by replacing all instances of " with \":

However, the replacement string '\"' is actually the same as '"', with \" interpreted as an identity escape, so the replacement does nothing. Instead, the replacement string should be '\\"':

  • Mozilla Developer Network: String escape notation.