oh no why
regress is a backtracking regular expression engine implemented in Rust, which targets JavaScript regular expression syntax. See the crate documentation for more.
It's fast, Unicode-aware, has no dependencies outside of std
, and has a big test suite.
The tester
binary can be used for some fun.
You can see how things get compiled with the dump-phases
crate feature:
> cargo run --features dump-phases --bin tester 'x{3,4}' 'i'
This was my first Rust program so no doubt there is room for improvement.
There's lots of stuff still missing, maybe you want to contribute?
(?<count>\d+)
[[:alpha:]]
\p{Sc}
$1
)std::str::pattern::Pattern
s
flag ("DotAll")tester
binary needs some real usage.^abc
still perform a string search. We should compute whether the whole regex is anchored, and optimize matching if so..*?
will eagerly compute their maximum match. This doesn't affect correctness but it does mean they may match more than they should.