to-regexp

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

Usage no npm install needed!

<script type="module">
  import toRegexp from 'https://cdn.skypack.dev/to-regexp';
</script>

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