diff --git a/lib/less/functions.js b/lib/less/functions.js
index <HASH>..<HASH> 100644
--- a/lib/less/functions.js
+++ b/lib/less/functions.js
@@ -222,8 +222,7 @@ tree.functions = {
         var str = subject.value;
 
         str = str.replace(new RegExp(pattern.value, flags ? flags.value : ""), replacement.value);
-
-        return new(tree.Quoted)('"' + str + '"', str);
+        return new(tree.Quoted)(subject.quote || '', str, subject.escaped);
     },
     '%': function (quoted /* arg, arg, ...*/) {
         var args = Array.prototype.slice.call(arguments, 1),
minor `replace` func improvement: preserve quote char and escaped flag.