Skip to content

Instantly share code, notes, and snippets.

@ezirmusitua
Last active September 10, 2019 21:41
Show Gist options
  • Save ezirmusitua/655a60c7261bf3c01f8ca9541d89fdfd to your computer and use it in GitHub Desktop.
Save ezirmusitua/655a60c7261bf3c01f8ca9541d89fdfd to your computer and use it in GitHub Desktop.
[Escape regex special characters] escape regex special characters with /, using in search #regex #javascript #node
function escapeRegExp(text) {
return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment