Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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');
//=> 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