Skip to content

Instantly share code, notes, and snippets.

@derhuerst
Created February 20, 2016 14:15
Show Gist options
  • Save derhuerst/918aac4cd31ced2c03c8 to your computer and use it in GitHub Desktop.
Save derhuerst/918aac4cd31ced2c03c8 to your computer and use it in GitHub Desktop.
escaping regular expression chars
// from http://blog.simonwillison.net/post/57956816139/escape
module.exports = (regex) => regex.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment