I am refering to code from Case insensitive string replacement in JavaScript?:
RegExp.escape = function(str)
{
var specials = new RegExp("[.*+?|()\\[\\]{}\\\\]", "g"); // .*+?|()[]{}\
return str.replace(specials, "\\$&");
}
What does \\$&
mean?
I think \\
escapes the \
character. Then $&
, I thought it should be $1
to match the 1st match? tho $1
does not work right