Here is my current javascript implementation:
EscapeForRegex = function(input) {
var specials = ["[", "\\", "^", "$", ".", "|", "?", "*", "+", "(", ")", "{", "}"]
for (var k in specials) {
var special = specials[k];
input = input.replace(new window.RegExp("\\" + special, "g"), "\\" + special);
}
return input;
};
But when I compare my code to the information provided at http://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex.escape.aspx, I noticed two differences.
I included the character ], which the reference page does not. Do we really need to include ]? (I understand it's in a different language, but my code is in javascript)
I missed out the character #. Is the # symbol considered special in javascript regex?