Escape RegExp special characters
JavaScript
Switch branches/tags
Clone or download
Latest commit db124a3 Feb 22, 2016
Permalink
Failed to load latest commit information.
.editorconfig tweaks Dec 19, 2015
.gitattributes init Jun 24, 2014
.gitignore init Jun 24, 2014
.travis.yml tweaks Dec 19, 2015
index.js tweaks Dec 19, 2015
license init Jun 24, 2014
package.json 1.0.5 Feb 21, 2016
readme.md tweaks Oct 5, 2015
test.js tweaks Dec 19, 2015

readme.md

escape-string-regexp Build Status

Escape RegExp special characters

Install

$ npm install --save escape-string-regexp

Usage

const escapeStringRegexp = require('escape-string-regexp');

const escapedString = escapeStringRegexp('how much $ for a unicorn?');
//=> 'how much \$ for a unicorn\?'

new RegExp(escapedString);

License

MIT © Sindre Sorhus