🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

escape-string-regexp-node

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

escape-string-regexp-node

Escape Regexp string function for nodejs

1.0.2
latest
Version published
Weekly downloads
2.1K
-38.8%
Maintainers
1
Weekly downloads
 
Created

escape-string-regexp-node

Escape RegExp special characters in Node.js

Written originally by sindresorhus (escape-string-regexp)

Install

$ npm install escape-string-regexp-node

Usage

const escapeRegexp = require("escape-string-regexp-node");
// Typescript
import escapeRegexp from 'escape-string-regexp-node';

const escapedString = escapeRegexp('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.

FAQs

Package last updated on 19 Nov 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts