1.0.1 • Published 4 years ago

retemplate v1.0.1

Weekly downloads
3
License
Apache-2.0
Repository
github
Last release
4 years ago

retemplate

Regular Expressions using Tagged Templates

Installation

npm i retemplate

Usage

import { R } from "retemplate";

// composing regular expressions with tagged templates:
const unsafe = "hello?";
const part = R`(?<part>${unsafe})`;
const whole = R`say ${part}`;
const re = new RegExp(whole); // re = /say (?:(?<part>hello\?))/
re.test("say hello?"); // true

// composite matchers
const results = R.matchAll({
    [R`foo`]: 0,
    [R`bar(\d)`]: (_, cap) => parseInt(cap),
    [R`baz`]: R.BREAK,
    [R`quxx`]: 3
}, "foo bar1 bar2 baz quxx");

result; // [0, 1, 2]
1.0.1

4 years ago

1.0.0

4 years ago

0.0.5

4 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago