commonly.typescript/templates
Creates a RegExp object from a Tagged Template Literal or a string pattern.
Flags are passed as a property or chain of properties of the regexp
tag. Each flags property can be called as a function with a boolean condition argument to ascertain such flags.
interface regexp {
(strings: TemplateStringsArray, ...keys: string[]): RegExp;
(pattern: string): RegExp;
[flags]: regexp;
[flags]: (condition: boolean) => regexp;
}
regexp('<.+>') == /<.+>/;
regexp`\b(${ ['hello', 'world'].join('|') })\b` == /\b(hello|world)\b/;
regexp.gi`another regexp` == /another regexp/gi;
regexp.g.m(true)`conditional m flag` == /conditional m flag/gm;