Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript escape regex

function escapeRegExp(input) {
	const source = typeof input === 'string' || input instanceof String ? input : '';
	return source.replace(/[-[/]{}()*+?.,^$|#s]/g, '$&');
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #javascript #escape #regex
ADD COMMENT
Topic
Name
4+6 =