Skip to content

lekterable/is-regexy

Repository files navigation

is-regexy npm build codecov management: perfekt👌

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

License

MIT