As you know, functions such as replace-regexp-in-string
and replace-match
have an argument LITERAL, meaning ...
If optional ... arg LITERAL is non-nil, insert NEWTEXT literally.
Otherwise treat ‘\’ as special ...
My intent is to replace all occurrences of a single-quote with a back-slash followed by a single-quote. However, the output does not evaluate that way:
(replace-regexp-in-string "'" "\'" "a'b'c" nil t)
"a'b'c"
(replace-regexp-in-string "'" "\\'" "a'b'c" nil t)
"a\\'b\\'c"
The result I need, by hook or by crook, is:
"a\'b\'c"