re-quote-replacement

added
1.5

ns
clojure.string

type
function

(re-quote-replacement replacement)

Given a replacement string that you wish to be a literal
replacement for a pattern match in replace or replace-first, do the
necessary escaping of special characters in the replacement.

                ;; Special characters are escaped

(use '[clojure.string :only (re-quote-replacement)])

user=> (re-quote-replacement "string \\\\ $")
"string \\\\\\\\ \\\\$"