# safe-regex-test

> Give a regex, get a robust predicate function that tests it against a string.

Latest version **1.1.0** (published 2024-12-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install safe-regex-test
pnpm add safe-regex-test
yarn add safe-regex-test
bun add safe-regex-test
```

## Health

**Score 50/100 (C)** — status: stable.

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

Warnings: low downloads.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2024-12-12 |
| First published | 2022-09-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >= 0.4 |
| Dependencies | 3 |
| Unpacked size | 11.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 7 |
| Author | Jordan Harband |
| Maintainers | ljharb |
| Keywords | regex, regexp, test, tester, safe, robust, exec |

## Links

- npm: https://www.npmjs.com/package/safe-regex-test
- Repository: https://github.com/ljharb/safe-regex-test
- Homepage: https://github.com/ljharb/safe-regex-test#readme
- Issues: https://github.com/ljharb/safe-regex-test/issues
- Funding: https://github.com/sponsors/ljharb
- npm.io page: https://npm.io/package/safe-regex-test

## Dependencies (3)

- [is-regex](https://npm.io/package/is-regex.md) ^1.2.1
- [es-errors](https://npm.io/package/es-errors.md) ^1.3.0
- [call-bound](https://npm.io/package/call-bound.md) ^1.0.2

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [vest](https://npm.io/package/vest.md) — 50.1K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads

## Recent versions

- 1.1.0 (latest) — 2024-12-12
- 1.0.3 — 2024-02-06
- 1.0.2 — 2024-01-11
- 1.0.1 — 2024-01-09
- 1.0.0 — 2022-09-22

## README

# safe-regex-test <sup>[![Version Badge][npm-version-svg]][package-url]</sup>

[![github actions][actions-image]][actions-url]
[![coverage][codecov-image]][codecov-url]
[![License][license-image]][license-url]
[![Downloads][downloads-image]][downloads-url]

[![npm badge][npm-badge-png]][package-url]

Give a regex, get a robust predicate function that tests it against a string. This will work even if `RegExp.prototype` is altered later.

## Getting started

```sh
npm install --save safe-regex-test
```

## Usage/Examples

```js
var regexTester = require('safe-regex-test');
var assert = require('assert');

var tester = regexTester('a');
assert.ok(tester('a'));
assert.notOk(tester('b'));
```

## Tests
Simply clone the repo, `npm install`, and run `npm test`

[package-url]: https://npmjs.org/package/safe-regex-test
[npm-version-svg]: https://versionbadg.es/ljharb/safe-regex-test.svg
[deps-svg]: https://david-dm.org/ljharb/safe-regex-test.svg
[deps-url]: https://david-dm.org/ljharb/safe-regex-test
[dev-deps-svg]: https://david-dm.org/ljharb/safe-regex-test/dev-status.svg
[dev-deps-url]: https://david-dm.org/ljharb/safe-regex-test#info=devDependencies
[npm-badge-png]: https://nodei.co/npm/safe-regex-test.png?downloads=true&stars=true
[license-image]: https://img.shields.io/npm/l/safe-regex-test.svg
[license-url]: LICENSE
[downloads-image]: https://img.shields.io/npm/dm/safe-regex-test.svg
[downloads-url]: https://npm-stat.com/charts.html?package=safe-regex-test
[codecov-image]: https://codecov.io/gh/ljharb/safe-regex-test/branch/main/graphs/badge.svg
[codecov-url]: https://app.codecov.io/gh/ljharb/safe-regex-test/
[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/ljharb/safe-regex-test
[actions-url]: https://github.com/ljharb/safe-regex-test/actions

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