re-template-tag: easily compose regular expressions
This package provides the template tag re
for composing regular expressions.
Basic syntax
Syntax: the following two expressions produce the same regular expression.
re`/abc/gu`/abc/gu
Composing regular expressions
; const RE_YEAR = //;const RE_MONTH = //;const RE_DAY = //;const RE_DATE = re`/^--$/u`; RE_DATE; // true
More information
- Take a look at the unit tests.
- Check out the blog post on re-template-tag.
Acknowledgement
The syntax for separating flags from the actual regular expression is based on an idea by Mathias Bynens.