Skip to content

trapcodeio/escape-string-regexp-node

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.


About

Escape Regexp String Function written in typescript for Nodejs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published