|
1 |
| -is-regex |
2 |
| -======== |
| 1 | +#is-regex <sup>[![Version Badge][2]][1]</sup> |
| 2 | + |
| 3 | +[![Build Status][3]][4] [![dependency status][5]][6] [![dev dependency status][7]][8] |
| 4 | + |
| 5 | +[![npm badge][11]][1] |
| 6 | + |
| 7 | +[![browser support][9]][10] |
3 | 8 |
|
4 | 9 | Is this value a JS regex?
|
| 10 | + |
| 11 | +## Example |
| 12 | + |
| 13 | +```js |
| 14 | +var isRegex = require('is-regex'); |
| 15 | +var assert = require('assert'); |
| 16 | + |
| 17 | +assert.notOk(isRegex(undefined)); |
| 18 | +assert.notOk(isRegex(null)); |
| 19 | +assert.notOk(isRegex(false)); |
| 20 | +assert.notOk(isRegex(true)); |
| 21 | +assert.notOk(isRegex(42)); |
| 22 | +assert.notOk(isRegex('foo')); |
| 23 | +assert.notOk(isRegex(function () {})); |
| 24 | +assert.notOk(isRegex([])); |
| 25 | +assert.notOk(isRegex({})); |
| 26 | + |
| 27 | +assert.ok(isRegex(/a/g)); |
| 28 | +assert.ok(isRegex(new RegExp('a', 'g'))); |
| 29 | +``` |
| 30 | + |
| 31 | +## Tests |
| 32 | +Simply clone the repo, `npm install`, and run `npm test` |
| 33 | + |
| 34 | +[1]: https://npmjs.org/package/is-regex |
| 35 | +[2]: http://vb.teelaun.ch/ljharb/is-regex.svg |
| 36 | +[3]: https://travis-ci.org/ljharb/is-regex.png |
| 37 | +[4]: https://travis-ci.org/ljharb/is-regex |
| 38 | +[5]: https://david-dm.org/ljharb/is-regex.png |
| 39 | +[6]: https://david-dm.org/ljharb/is-regex |
| 40 | +[7]: https://david-dm.org/ljharb/is-regex/dev-status.png |
| 41 | +[8]: https://david-dm.org/ljharb/is-regex#info=devDependencies |
| 42 | +[9]: https://ci.testling.com/ljharb/is-regex.png |
| 43 | +[10]: https://ci.testling.com/ljharb/is-regex |
| 44 | +[11]: https://nodei.co/npm/is-regex.png?downloads=true&stars=true |
| 45 | + |
0 commit comments