is-regex (1.2.1)

Published 2026-02-24 13:58:37 +00:00 by atheaadmin

Installation

registry=
npm install is-regex@1.2.1
"is-regex": "1.2.1"

About this package

is-regex Version Badge

github actions coverage dependency status dev dependency status License Downloads

npm badge

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

Example

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

Dependencies

Dependencies

ID Version
call-bound ^1.0.2
gopd ^1.2.0
has-tostringtag ^1.0.2
hasown ^2.0.2

Development Dependencies

ID Version
@arethetypeswrong/cli ^0.17.1
@ljharb/eslint-config ^21.1.1
@ljharb/tsconfig ^0.2.2
@types/core-js ^2.5.8
@types/for-each ^0.3.3
@types/tape ^5.6.5
auto-changelog ^2.5.0
core-js ^3.39.0
eclint ^2.8.1
encoding ^0.1.13
eslint =8.8.0
for-each ^0.3.3
in-publish ^2.0.1
npmignore ^0.3.1
nyc ^10.3.2
safe-publish-latest ^2.0.0
tape ^5.9.0
typescript ^5.8.0-dev.20241129

Keywords

regex regexp is regular expression regular expression
Details
npm
2026-02-24 13:58:37 +00:00
0
Jordan Harband
MIT
latest
12 KiB
Assets (1)
Versions (1) View all
1.2.1 2026-02-24