Exciting news!Announcing our $4.6M Series Seed. Learn more
Socket
LoveBlogFAQ
Install
Log in

escape-string-regexp

Package Overview
Dependencies
0
Maintainers
1
Versions
10
Issues
File Explorer

Advanced tools

escape-string-regexp

Escape RegExp special characters

    5.0.0latest

Version published
Maintainers
1
Yearly downloads
2,932,044,063
increased by92.45%

Weekly downloads

Changelog

Source

Breaking

  • Require Node.js 12 aebb6e8
  • This package is now pure ESM. Please read this.

https://github.com/sindresorhus/escape-string-regexp/compare/v4.0.0...v5.0.0

Readme

Source

escape-string-regexp

Escape RegExp special characters

Install

$ npm install escape-string-regexp

Usage

import escapeStringRegexp from '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.

Keywords

Socket

Product

Subscribe to our newsletter

Get open source security insights delivered straight into your inbox. Be the first to learn about new features and product updates.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc