How to escape regular expression in javascript ?
- by Relax
My codes is like
pattern = 'arrayname[1]'; // fetch from dom, make literal here just for example
reg = new RegExp(RegExp.quote(pattern), 'g');
mystring.replace(reg, 'arrayname[2]');
But it just cannot get running with error message says: "RegExp.quote is not a function", am i missing something simple?