Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 1 day 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 6 years ago)
- Default Branch: master
- Last Pushed: 2018-03-25T14:36:09.000Z (over 6 years ago)
- Last Synced: 2024-04-26T13:40:11.947Z (8 months 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 [![Build Status](https://travis-ci.org/Mottie/is-regexp-string.svg?branch=master)](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');
//=> trueisRegexpString('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