Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

is-supported-regexp-flag

sindresorhus2.4mMIT2.0.0

Check whether a RegExp flag is supported

regexp, regex, check, is, support, supported, valid, flag

readme

is-supported-regexp-flag

Check whether a RegExp flag is supported

Install

$ npm install is-supported-regexp-flag

Usage

import isSupportedRegexpFlag from 'is-supported-regexp-flag';

isSupportedRegexpFlag('g'); // As in `/foo/g`
//=> true

isSupportedRegexpFlag('u');
//=> false

The RegExp constructor throws if you're trying to use unsupported flags. This is a nicer way to check for support.