is-regexy
v2.0.0
Published
Check if given string is a valid regular expression.
Downloads
4
Maintainers
Readme
is-regexy
A very simple library for checking if a given value (Regex object OR string) is a valid regular expression.
Useful when you want to allow users to pass regex patterns as input.
Example
const isRegexy = require('is-regexy') // CommonJS
// OR
import isRegexy from 'is-regexy' // ES modules
isRegexy('foo') // false
isRegexy(/foo/) // true
isRegexy(new RegExp('foo')) // true
isRegexy('/foo/') // true
isRegexy('/foo/ig') // true
isRegexy('/(epic|feat|fix|chore)/DEV-\\d{4}/i') //true