I've got this implementation in javascript:
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;
};
however when i compare my implementation to the page at http://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex.escape.aspx, i find 2 differences.
I've included ] but the page doesn't do so. is it true that we do not have to include the ] ? (apparently I'm not doubting that page, but since my implementation is in javascript and not c#/vb..)
I've missed out #. is the # symbol special in javascript regex?