special characters regex in javascript code example
Example: javascript escape regex
function escapeRegExp(input) {
const source = typeof input === 'string' || input instanceof String ? input : '';
return source.replace(/[-[/\]{}()*+?.,\\^$|#\s]/g, '\\$&');
}