Skip to content

Instantly share code, notes, and snippets.

@bugventure
Created September 15, 2016 09:22
Show Gist options
  • Save bugventure/f1d7997c2bb6e56981389fdd73d762ae to your computer and use it in GitHub Desktop.
Save bugventure/f1d7997c2bb6e56981389fdd73d762ae to your computer and use it in GitHub Desktop.
// Source: http://stackoverflow.com/questions/2593637/how-to-escape-regular-expression-in-javascript
RegExp.quote = function(str) {
return (str+'').replace(/[.?*+^$[\]\\(){}|-]/g, "\\$&");
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment