escape-string-regexp
TypeScript icon, indicating that this package has built-in type declarations

1.0.5 • Public • Published

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

Package Sidebar

Install

npm i escape-string-regexp@1.0.5

Version

1.0.5

License

MIT

Last publish

Collaborators

  • sindresorhus