# string-escape-regex

> A tiny function for escaping a string to be used as the source in a regex.

Latest version **1.0.1** (published 2025-01-19) · MIT license · 0 weekly downloads

## Install

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

## Health

**Score 40/100 (D)** — status: maintenance-mode.

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

Warnings: low downloads.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2025-01-19 |
| First published | 2022-05-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 2.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Maintainers | fabiospampinato |
| Keywords | string, escape, regex, regexp |

## Links

- npm: https://www.npmjs.com/package/string-escape-regex
- Repository: https://github.com/fabiospampinato/string-escape-regex
- Homepage: https://github.com/fabiospampinato/string-escape-regex#readme
- Issues: https://github.com/fabiospampinato/string-escape-regex/issues
- npm.io page: https://npm.io/package/string-escape-regex

## 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

- 1.0.1 (latest) — 2025-01-19
- 1.0.0 — 2022-05-06

## README

# String Escape Regex

A tiny function for escaping a string to be used as the source in a regex.

## Install

```sh
npm install string-escape-regex
```

## Usage

```ts
import escape from 'string-escape-regex';

// Let's escape a string to be used in a regex

escape ( 'foo()' ); // => 'foo\\(\\)'
```

## License

MIT © Fabio Spampinato

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