escape-string-regexp
    Overview
    Documentation
    Tutorials
    Chat
    Insights
    Code
    Dependencies
    Contributors
    Jobs

escape-string-regexp

Escape RegExp special characters

2.0.0  •  Updated 1 years ago  •  by Sindre Sorhus  •  MIT License

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.

License

MIT © Sindre Sorhus

Popularity

Maintenance

Development

Last ver 1 year ago
Created 6 years ago
Last commit 1 month ago
3 months between commits

Technology

Node version: 10.15.1
3.3K unpacked

Compliance

MIT License
OSI Approved
0 vulnerabilities

Contributors

6 contributors
Sindre Sorhus
Maintainer, 13 commits, 4 merges
Joshua Appelman
7 commits
Charmander
2 commits, 2 PRs
Joshua Boy Nicolai Appelman
2 commits
Works at Google
Dimitri Benin
1 commits, 1 PRs
Corey Farrell
1 commits, 1 PRs
Works at CFWare, LLC

Tags

escape
regex
regexp
re
regular
expression
string
str
special
characters
Openbase helps developers choose among and use millions of open-source packages, so they can build amazing products faster.
FacebookTwitterLinkedIn
© 2020 Devstore, Inc.