is-regex
Is this value a JS regex? Works cross-realm/iframe, and despite ES6 @@toStringTag
Last updated 3 years ago by ljharb .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install is-regex 
SYNC missed versions from official npm registry.

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

Current Tags

  • 1.1.4                                ...           latest (3 years ago)

12 Versions

  • 1.1.4                                ...           3 years ago
  • 1.1.3                                ...           4 years ago
  • 1.1.2                                ...           4 years ago
  • 1.1.1                                ...           4 years ago
  • 1.1.0                                ...           4 years ago
  • 1.0.5                                ...           5 years ago
  • 1.0.4                                ...           8 years ago
  • 1.0.3                                ...           10 years ago
  • 1.0.2                                ...           10 years ago
  • 1.0.1                                ...           10 years ago
  • 1.0.0                                ...           10 years ago
  • 0.0.0                                ...           11 years ago
Maintainers (1)
Downloads
Total 2
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (2)
Dev Dependencies (10)

© 2010 - cnpmjs.org x YWFE | Home | YWFE