I want to do a string search inside a string. Simply saying MySTR.search(Needle).
MySTR.search(Needle)
The problem occurs when this needle string contains speci
needle
Duplicate of https://stackoverflow.com/a/6969486/151312
This is proper as per MDN (see explanation in post above):
function escapeRegExp(str) { return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); }