Crates.io | regress |
lib.rs | regress |
version | 0.10.1 |
source | src |
created_at | 2020-05-25 00:17:36.57285 |
updated_at | 2024-09-02 19:30:05.718565 |
description | A regular expression engine targeting EcmaScript syntax |
homepage | |
repository | https://github.com/ridiculousfish/regress |
max_upload_size | |
id | 245399 |
size | 2,450,061 |
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 few dependencies, and has a big test suite. It makes fewer guarantees than the regex
crate but it enables more syntactic features, such as backreferences and lookaround assertions.
The regress-tool
binary can be used for some fun.
You can see how things get compiled with the dump-phases
cli flag:
> cargo run 'x{3,4}' 'i' --dump-phases
You can run a little benchmark too, for example:
> cargo run --release -- 'abcd' 'i' --bench ~/3200.txt
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?
$1
)std::str::pattern::Pattern
^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.