Mottie / is-regexp-string

Check if a string is a regular expression

Home Page:https://npm.im/is-regexp-string

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

is-regexp-string Build Status

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

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 - Check if a value is a regular expression

License

MIT

About

Check if a string is a regular expression

https://npm.im/is-regexp-string

License:MIT License


Languages

Language:JavaScript 100.0%