1
|
#is-regex <sup>[![Version Badge][2]][1]</sup>
|
2
|
|
3
|
[![Build Status][3]][4]
|
4
|
[![dependency status][5]][6]
|
5
|
[![dev dependency status][7]][8]
|
6
|
[![License][license-image]][license-url]
|
7
|
[![Downloads][downloads-image]][downloads-url]
|
8
|
|
9
|
[![npm badge][11]][1]
|
10
|
|
11
|
[![browser support][9]][10]
|
12
|
|
13
|
Is this value a JS regex?
|
14
|
This module works cross-realm/iframe, and despite ES6 @@toStringTag.
|
15
|
|
16
|
## Example
|
17
|
|
18
|
```js
|
19
|
var isRegex = require('is-regex');
|
20
|
var assert = require('assert');
|
21
|
|
22
|
assert.notOk(isRegex(undefined));
|
23
|
assert.notOk(isRegex(null));
|
24
|
assert.notOk(isRegex(false));
|
25
|
assert.notOk(isRegex(true));
|
26
|
assert.notOk(isRegex(42));
|
27
|
assert.notOk(isRegex('foo'));
|
28
|
assert.notOk(isRegex(function () {}));
|
29
|
assert.notOk(isRegex([]));
|
30
|
assert.notOk(isRegex({}));
|
31
|
|
32
|
assert.ok(isRegex(/a/g));
|
33
|
assert.ok(isRegex(new RegExp('a', 'g')));
|
34
|
```
|
35
|
|
36
|
## Tests
|
37
|
Simply clone the repo, `npm install`, and run `npm test`
|
38
|
|
39
|
[1]: https://npmjs.org/package/is-regex
|
40
|
[2]: http://versionbadg.es/ljharb/is-regex.svg
|
41
|
[3]: https://travis-ci.org/ljharb/is-regex.svg
|
42
|
[4]: https://travis-ci.org/ljharb/is-regex
|
43
|
[5]: https://david-dm.org/ljharb/is-regex.svg
|
44
|
[6]: https://david-dm.org/ljharb/is-regex
|
45
|
[7]: https://david-dm.org/ljharb/is-regex/dev-status.svg
|
46
|
[8]: https://david-dm.org/ljharb/is-regex#info=devDependencies
|
47
|
[9]: https://ci.testling.com/ljharb/is-regex.png
|
48
|
[10]: https://ci.testling.com/ljharb/is-regex
|
49
|
[11]: https://nodei.co/npm/is-regex.png?downloads=true&stars=true
|
50
|
[license-image]: http://img.shields.io/npm/l/is-regex.svg
|
51
|
[license-url]: LICENSE
|
52
|
[downloads-image]: http://img.shields.io/npm/dm/is-regex.svg
|
53
|
[downloads-url]: http://npm-stat.com/charts.html?package=is-regex
|
54
|
|