compose-regexp
Advanced tools
Changelog
v0.6.2
2022-04-22
noBound(x)
matches where bound(x)
doesn't and vice-versa. Think /\B/
vs /\b/
.charSet.invert(x)
will succeed where x
doesn't and vice-versa. think /[^a-z]/
vs /[a-z]/
Changelog
v0.6.0 (things are getting serious)
2022-04-22
This version revamps the core to provide better support for the u
flag. The ref()
story is also far more robust. ref()
lets us introduce an atomic()
helper that prevents the engine from backtracking.
avoid()
becomes notAhead()
(mirroring the newly introduced lookBehind()
, notBehind()
scheme).\1
) are now updated when regexps that hold them are combined. sequence(/(.)\1/, /(.)\1/)
returns /(.)\1(.)\2/
ref()
now returns a thunk, to let one create back references programmatically. sequence(/(.)/, ref(1))
returns /(.)\1/
u
flag is now contagious, non-unicode RegExps are promoted to unicode when possible.m
or s
flag are converted into flagless equivalent that match the same input (e.g. /./s
=> /[^]/
)u
promotion and m
and s
folding, the combinators don't accept mixed flags as input.atomic(...exprs)
will create an atomic group that prevents backtracking into the expression once it has matched. ReDOS, begone! atomic()
is direction sensitive, see below).bound(pattern)
generalizes the /\b\
assertion to arbitrary character classes (or patterns, really)charSet.*()
methods let one do set arithmetics on character sets.sequence()
. Functions come in handy for look behind assertions.ref("label")
creates a named reference (/\k<label>/
).namedCapture("label", ...)
returns (/(?<label>...)/
)lookBehind()
and notBehind()
assertions.lookBehind(ref(1), capture(/\w/))
will be rejected. lookBehind(()=>[ref(1), capture(/\w/)])
however will do what you want, because the function is then evaluated in backward context.package.json
... to @Hypercubed who submitted a PR for an issue that was solved independently.
Changelog
v0.5.2
flags()
.Here be drgns...