https://github.com/mottie/is-regexp-string
Check if a string is a regular expression
https://github.com/mottie/is-regexp-string
check node regexp regular-expression string
Last synced: 7 months ago
JSON representation
Check if a string is a regular expression
- Host: GitHub
- URL: https://github.com/mottie/is-regexp-string
- Owner: Mottie
- License: mit
- Created: 2018-03-25T14:09:09.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-03-25T14:36:09.000Z (over 7 years ago)
- Last Synced: 2024-04-26T13:40:11.947Z (over 1 year ago)
- Topics: check, node, regexp, regular-expression, string
- Language: JavaScript
- Homepage: https://npm.im/is-regexp-string
- Size: 2.93 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: license
Awesome Lists containing this project
README
# is-regexp-string [](https://travis-ci.org/Mottie/is-regexp-string)
> Check if a string is a regular expression
* The string *must* include the opening & closing forward slash (`/`).
* Regular expression flags, e.g. `gim`, may be optionally included.
## Install
```
$ npm install is-regexp-string
```
## Usage
```js
const isRegexpString = require('is-regexp-string');
// The forward slashes of the regular expression are *required*
isRegexpString('/(foo|bar)/gi');
//=> true
isRegexpString('foo|bar');
//=> false
// Valid RegExp, but matches everything
isRegexpString('/foo|/');
//=> true
```
## Related
- [is-regexp](https://github.com/sindresorhus/is-regexp) - Check if a value is a regular expression
## License
MIT