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