README
regexr
Easily compose regular expressions. Doing this with strings would otherwise be tedious due to having to double-escape things.
Basic example:
import r from "regexr";
const int = /\d+/;
const USD = r`\${int}(\.${int})?`; // f.e. $3.45 or $5
(Note that int
is an instance of RegExp
and can be composed into the
template string, and the resulting USD
is also a RegExp
)
Regexr provides an ES6 template tag function that makes it easy to compose
RegExp
s using template strings without double-escaped hell.
In ES5 and below, we may try to compose the regular expressions like so:
const int = '\d+'
let USD = new RegExp('\