Skip to content

Instantly share code, notes, and snippets.

@Ultrabenosaurus
Forked from anonymous/regescape.js
Created January 7, 2013 12:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ultrabenosaurus/4474581 to your computer and use it in GitHub Desktop.
Save Ultrabenosaurus/4474581 to your computer and use it in GitHub Desktop.
// taken from http://stackoverflow.com/a/6969486/1734964
// saved for my own laziness
function escapeRegExp(str) {
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment