Revision: 9537
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at November 11, 2008 09:41 by kouphax
Initial Code
RegExp.escape = function(str) { var specials = new RegExp("[.*+?|()\\[\\]{}\\\\]", "g"); // .*+?|()[]{}\ return str.replace(specials, "\\$&"); }
Initial URL
http://stackoverflow.com/questions/280793/case-insensitive-string-replacement-in-javascript
Initial Description
Escape all special regex characters (.*+?|()[]{}\) from a string. Useful when dynamically building a Regular Expression object based on input text that could hold regex characters.
Initial Title
Escape Regular Expression Characters in String
Initial Tags
regex, javascript
Initial Language
JavaScript