You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

escape-string-regexp-node

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

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.0
Source
npmnpm
Version published
Weekly downloads
1.4K
-19.87%
Maintainers
1
Weekly downloads
 
Created
Source

escape-string-regexp-node

Escape RegExp special characters

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