sindresorhus/escape-string-regexp


Escape RegExp special characters

License: MIT

Language: JavaScript


escape-string-regexp Build Status

Escape RegExp special characters

Install

$ npm install escape-string-regexp

Usage

const escapeStringRegexp = require('escape-string-regexp');

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


Get professional support for this package with a Tidelift subscription
Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies.

Project Statistics

Sourcerank 19
Repository Size 15.6 KB
Stars 387
Forks 34
Watchers 16
Open issues 1
Dependencies 3
Contributors 5
Tags 9
Created
Last updated
Last pushed

Top Contributors See all

Sindre Sorhus Charmander Joshua Appelman Dimitri Benin Corey Farrell

Packages Referencing this Repo

escape-string-regexp
Escape RegExp special characters
Latest release v4.0.0 - Published - 387 stars
escape-string-regexp
Escape RegExp special characters
Latest release 4.0.0 - Updated - 387 stars
org.webjars.bowergithub.sindresorhus:escape-string-regexp
WebJar for escape-string-regexp
Latest release 2.0.0 - Updated - 387 stars
org.webjars.npm:escape-string-regexp
WebJar for escape-string-regexp
Latest release 2.0.0 - Updated - 387 stars
org.webjars.bower:escape-string-regexp
WebJar for escape-string-regexp
Latest release 1.0.5 - Published - 387 stars

Recent Tags See all

v4.0.0 April 23, 2020
v3.0.0 April 07, 2020
v2.0.0 April 17, 2019
v1.0.5 February 21, 2016
v1.0.4 December 19, 2015
v1.0.3 February 22, 2015
v1.0.2 September 13, 2014
v1.0.1 July 12, 2014
v1.0.0 June 24, 2014

Interesting Forks See all

percona/escape-string-regexp
Escape RegExp special characters
JavaScript - MIT - Last pushed - 1 stars - 1 forks

Something wrong with this page? Make a suggestion

Last synced: 2020-06-03 08:16:22 UTC

Login to resync this repository