#regex #regexp

no-std regress

A regular expression engine targeting EcmaScript syntax

13 unstable releases (6 breaking)

0.7.1 Aug 25, 2023
0.6.0 Apr 28, 2023
0.5.0 Mar 13, 2023
0.4.1 Jul 9, 2021
0.1.3 May 26, 2020

#115 in Text processing

Download history 17329/week @ 2023-08-17 64544/week @ 2023-08-24 62838/week @ 2023-08-31 104850/week @ 2023-09-07 91889/week @ 2023-09-14 87107/week @ 2023-09-21 106003/week @ 2023-09-28 111011/week @ 2023-10-05 106034/week @ 2023-10-12 108089/week @ 2023-10-19 112935/week @ 2023-10-26 113536/week @ 2023-11-02 123204/week @ 2023-11-09 60174/week @ 2023-11-16 26388/week @ 2023-11-23 30518/week @ 2023-11-30

262,239 downloads per month
Used in 38 crates (14 directly)


25K SLoC

regress - REGex in Rust with EcmaScript Syntax

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.

Fun Tools

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

Want to contribute?

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?

Currently Missing Features

  • An API for replacing a string while substituting in capture groups (e.g. with $1)
  • An API for escaping a string to make it a literal
  • Implementing std::str::pattern::Pattern

Missing Performance Optimizations

  • Anchored matches like ^abc still perform a string search. We should compute whether the whole regex is anchored, and optimize matching if so.
  • Non-greedy loops like .*? will eagerly compute their maximum match. This doesn't affect correctness but it does mean they may match more than they should.
  • Pure literal searches should use Boyer-Moore or etc.
  • There are lots of vectorization opportunities.


~26K SLoC