escape-string-regexp's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
$ npm install escape-string-regexp
Once installed, you can utilize it in your code. Here's a simple usage example:
import escapeStringRegexp from 'escape-string-regexp'; const escapedString = escapeStringRegexp('How much $ for a 🦄?'); console.log(escapedString); // Output: 'How much \\$ for a 🦄\\?'
This example takes the string 'How much $ for a 🦄?' and escapes the dollar sign, which is a special RegExp character. The resulting string can then be safely used to create a new RegExp.
The main documentation for escape-string-regexp is the contents of its README file on the GitHub repository, which can be found at https://github.com/sindresorhus/escape-string-regexp. This README provides the fundamental details of what the package does and how to use it.