How to escape all special charactors (modifiers) in the pattern?
In this snippet of code the var input
contains a modifier *
.. How to escape all special characters in the input (pattern) variable?
var input = '*dog',
regexp = new RegExp(input, 'ig'),
str = 'a *dog and a cat';
if(str.search(regexp) >= 0){
console.log('found!');
}
else{
console.log('not found!');
}