JSPM

@d-fischer/escape-string-regexp

5.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1721
  • Score
    100M100P100Q123851F
  • License MIT

Escape RegExp special characters

Package Exports

  • @d-fischer/escape-string-regexp

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@d-fischer/escape-string-regexp) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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.


Get professional support for this package with a Tidelift subscription
Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies.