tree: 38489d31e951559c242758d217e9bdba4179918d
  1. index.d.ts
  2. index.js
  3. license
  4. package.json
  5. readme.md
node_modules/mocha/node_modules/escape-string-regexp/readme.md

escape-string-regexp Build Status

Escape RegExp special characters

Install

$ npm install escape-string-regexp

Usage

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

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

new RegExp(escapedString);

You can also use this to escape a string that is inserted into the middle of a regex, for example, into a character class.