Step 3: Usage
Treat custom tokens like a built-in token
Custom tokens are integrated as part of readable-regexp. So you can use them just like how you use a built-in token.
Start an expression with a custom token returned by defineToken
const expr1 = notExactly`foo`.exactly`bar`.toRegExp();
// /(?!foo)[^]{3}bar/
Use custom tokens as part of an expression chain
const expr2 = capture.severity.matchAll.toRegExp();
// /^(error|warning|info|debug)$/e
Use custom tokens from the
r
shorthand
const expr3 = r.alpha(false).toRegExp();
// /[a-z]/
Last updated