js
RegExp.escape= function(s) {
return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
};
regex - Is there a RegExp.escape function in Javascript? - Stack Overflow regex - How to escape regular expression special characters using javascript? - Stack Overflow