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

Package detail

to-regexp

zeekay10MIT0.1.7

Convert globs, strings, and arrays to a single RegExp.

regex

readme

to-regexp

Turns wild card-style glob ('foo*') and stringified regular expressions ('/foo.*/') into RegExp objects.

Install

npm install to-regexp

Usage

var toRegExp = require('to-regexp');

var re = toRegExp('foo*');
re.test('foo'); // true
re.test('foobar'); // true

var re = toRegExp('/foo.*/');
re.test('foo'); // true
re.test('foobar'); // true