# escape-string-regexp

> Escape RegExp special characters

Latest version **5.0.0** (published 2021-04-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install escape-string-regexp
pnpm add escape-string-regexp
yarn add escape-string-regexp
bun add escape-string-regexp
```

## Health

**Score 43/100 (D)** — status: abandoned.

Positive: has types package; esm support; no vulnerabilities; high maintenance score; high quality score.

Warnings: low downloads.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 5.0.0 |
| Published | 2021-04-17 |
| First published | 2014-06-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/escape-string-regexp) |
| Module format | ESM |
| Node | >=12 |
| Dependencies | 0 |
| Unpacked size | 3.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 593 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | escape, regex, regexp, regular, expression, string, special, characters |

## Links

- npm: https://www.npmjs.com/package/escape-string-regexp
- Repository: https://github.com/sindresorhus/escape-string-regexp
- Homepage: https://github.com/sindresorhus/escape-string-regexp#readme
- Issues: https://github.com/sindresorhus/escape-string-regexp/issues
- Funding: https://github.com/sponsors/sindresorhus
- npm.io page: https://npm.io/package/escape-string-regexp

## Alternatives

- [@mce/gif](https://npm.io/package/@mce/gif.md) — 2.6K weekly downloads
- [cleanse](https://npm.io/package/cleanse.md) — 173 weekly downloads
- [str](https://npm.io/package/str.md) — 127 weekly downloads
- [naming](https://npm.io/package/naming.md) — 95 weekly downloads
- [tap-telco-api](https://npm.io/package/tap-telco-api.md) — 19 weekly downloads

## Recent versions

- 5.0.0 (latest) — 2021-04-17
- 4.0.0 — 2020-04-23
- 3.0.0 — 2020-04-07
- 2.0.0 — 2019-04-17
- 1.0.5 — 2016-02-21
- 1.0.4 — 2015-12-19
- 1.0.3 — 2015-02-22
- 1.0.2 — 2014-09-13
- 1.0.1 — 2014-07-12
- 1.0.0 — 2014-06-24

## README

# escape-string-regexp

> Escape RegExp special characters

## Install

```
$ npm install escape-string-regexp
```

## Usage

```js
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.

---

<div align="center">
	<b>
		<a href="https://tidelift.com/subscription/pkg/npm-escape-string-regexp?utm_source=npm-escape-string-regexp&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
	</b>
	<br>
	<sub>
		Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
	</sub>
</div>

---
_Source: https://npm.io/package/escape-string-regexp · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
