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

regexp-escape-x

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

regexp-escape-x

ECMAScript proposed RegExp.escape.

3.1.2
latest
Source
npmnpm
Version published
Weekly downloads
176
351.28%
Maintainers
1
Weekly downloads
 
Created
Source

Travis status Dependency status devDependency status npm version jsDelivr hits bettercodehub score Coverage Status

regexp-escape-x

ECMAScript proposed RegExp.escape.

See: RegExp.escape

module.exports(string)string

Method to safely escape RegExp special tokens for use in new RegExp.

Kind: Exported function
Returns: string - The escaped string.
Throws:

  • TypeError If string is null or undefined or not coercible.
ParamTypeDescription
stringstringThe string to be escaped.

Example

import regexpEscape from 'regexp-escape-x';

const str = 'hello. how are you?';
const regex = new RegExp(regexpEscape(str), 'g');
console.log(String(regex)); // '/hello\. how are you\?/g'

Keywords

regexp

FAQs

Package last updated on 28 Aug 2019

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