# is-regex

> Is this value a JS regex? Works cross-realm/iframe, and despite ES6 @@toStringTag

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

## Install

```sh
npm install is-regex
pnpm add is-regex
yarn add is-regex
bun add is-regex
```

## Health

**Score 45/100 (D)** — status: stable.

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

Warnings: low downloads; no esm support.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 1.2.1 |
| Published | 2024-12-12 |
| First published | 2014-01-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >= 0.4 |
| Dependencies | 4 |
| Unpacked size | 34.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 24 |
| Author | Jordan Harband |
| Maintainers | ljharb |
| Keywords | regex, regexp, is, regular expression, regular, expression |

## Links

- npm: https://www.npmjs.com/package/is-regex
- Repository: https://github.com/inspect-js/is-regex
- Issues: https://github.com/inspect-js/is-regex/issues
- Funding: https://github.com/sponsors/ljharb
- npm.io page: https://npm.io/package/is-regex

## Dependencies (4)

- [gopd](https://npm.io/package/gopd.md) ^1.2.0
- [hasown](https://npm.io/package/hasown.md) ^2.0.2
- [call-bound](https://npm.io/package/call-bound.md) ^1.0.2
- [has-tostringtag](https://npm.io/package/has-tostringtag.md) ^1.0.2

## Alternatives

- [memory-cache](https://npm.io/package/memory-cache.md) — 795.0K weekly downloads
- [@httptoolkit/proxy-agent](https://npm.io/package/@httptoolkit/proxy-agent.md) — 11.2K weekly downloads
- [express-cache-controller](https://npm.io/package/express-cache-controller.md) — 5.3K weekly downloads
- [http-cache-middleware](https://npm.io/package/http-cache-middleware.md) — 4.5K weekly downloads
- [cache2](https://npm.io/package/cache2.md) — 1.5K weekly downloads

## Recent versions

- 1.2.1 (latest) — 2024-12-12
- 1.2.0 — 2024-11-30
- 1.1.4 — 2021-08-06
- 1.1.3 — 2021-05-08
- 1.1.2 — 2021-02-01
- 1.1.1 — 2020-08-04
- 1.1.0 — 2020-06-04
- 1.0.5 — 2019-12-15
- 1.0.4 — 2017-02-18
- 1.0.3 — 2015-01-30
- 1.0.2 — 2015-01-29
- 1.0.1 — 2015-01-28
- 1.0.0 — 2014-05-19
- 0.0.0 — 2014-01-15

## README

# is-regex <sup>[![Version Badge][2]][1]</sup>

[![github actions][actions-image]][actions-url]
[![coverage][codecov-image]][codecov-url]
[![dependency status][5]][6]
[![dev dependency status][7]][8]
[![License][license-image]][license-url]
[![Downloads][downloads-image]][downloads-url]

[![npm badge][11]][1]

Is this value a JS regex?
This module works cross-realm/iframe, and despite ES6 @@toStringTag.

## Example

```js
var isRegex = require('is-regex');
var assert = require('assert');

assert.notOk(isRegex(undefined));
assert.notOk(isRegex(null));
assert.notOk(isRegex(false));
assert.notOk(isRegex(true));
assert.notOk(isRegex(42));
assert.notOk(isRegex('foo'));
assert.notOk(isRegex(function () {}));
assert.notOk(isRegex([]));
assert.notOk(isRegex({}));

assert.ok(isRegex(/a/g));
assert.ok(isRegex(new RegExp('a', 'g')));
```

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

[1]: https://npmjs.org/package/is-regex
[2]: https://versionbadg.es/inspect-js/is-regex.svg
[5]: https://david-dm.org/inspect-js/is-regex.svg
[6]: https://david-dm.org/inspect-js/is-regex
[7]: https://david-dm.org/inspect-js/is-regex/dev-status.svg
[8]: https://david-dm.org/inspect-js/is-regex#info=devDependencies
[11]: https://nodei.co/npm/is-regex.png?downloads=true&stars=true
[license-image]: https://img.shields.io/npm/l/is-regex.svg
[license-url]: LICENSE
[downloads-image]: https://img.shields.io/npm/dm/is-regex.svg
[downloads-url]: https://npm-stat.com/charts.html?package=is-regex
[codecov-image]: https://codecov.io/gh/inspect-js/is-regex/branch/main/graphs/badge.svg
[codecov-url]: https://app.codecov.io/gh/inspect-js/is-regex/
[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/inspect-js/is-regex
[actions-url]: https://github.com/inspect-js/is-regex/actions

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