regress

A backtracking regular expression engine for Rust that targets ECMAScript regexp syntax

Library
Cargo
v0.11.1
222stars
MIT OR Apache-2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
77/100Good
Development Activity92
Maintenance68
Community68
Maturity60
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
74/100Good
Architecture82
Code Quality80
Innovation75
Learning Curve60

regress is a Rust regular expression engine that implements ECMAScript (JavaScript) regexp semantics rather than the more restrictive syntax of Rust’s regex crate. It supports backreferences, lookaround assertions (including variable-width lookbehind with capture groups), and both PikeVM and classical-backtracking execution backends, making it a close match for tools that need to replicate exact JavaScript regex behavior — including UTF-16 surrogate-pair handling controlled by the ‘u’/‘v’ flags — in a Rust codebase.

What You Get

  • Full ECMAScript 2018+ regexp syntax support, including backreferences and variable-width lookbehind assertions with capture groups
  • Two selectable execution backends: a classical backtracking matcher and a PikeVM implementation (enabled via the backend-pikevm feature, on by default)
  • Accurate UTF-16/surrogate-pair matching semantics matching JavaScript’s ‘u’ and ‘v’ flag behavior
  • no_std + alloc support via the alloc feature for embedded or constrained environments
  • A large test suite including a dedicated PCRE test corpus (tests/pcre_tests.rs) alongside syntax-error, escape, and replacement test suites

Common Use Cases

  • Implementing JavaScript-compatible regex behavior inside a Rust-based JS engine, linter, or transpiler (e.g. matching engine behavior in tools like SWC or Deno-adjacent tooling)
  • Validating or replaying user-supplied JavaScript regexes in a Rust backend without embedding a JS runtime
  • Porting JavaScript-derived business logic (validation rules, string parsing) to Rust while preserving exact regex-match behavior
  • Building developer tools that need to explain or debug JavaScript regex matches (e.g. regex playgrounds, static analyzers) from a Rust codebase

Under The Hood

Architecture: the crate is organized around a classic regex-engine pipeline — parse.rs builds an AST/IR (ir.rs) from ECMAScript regexp syntax, optimizer.rs rewrites it, emit.rs compiles it to bytecode (insn.rs), and execution is handled by either classicalbacktrack.rs or pikevm.rs depending on the selected backend, with unicode.rs/unicodetables.rs/charclasses.rs providing Unicode-aware character class support and cursor.rs/indexing.rs abstracting over UTF-8/UTF-16 position handling. Tech Stack: Rust (2024 edition) organized as a Cargo workspace with regress-tool (a CLI/debug tool) and gen-unicode (Unicode table generation) as workspace members alongside the core crate; runtime dependencies are minimal (memchr, optional hashbrown for no_std+alloc), keeping the dependency footprint small relative to its syntax coverage. Code Quality: the tests/ directory includes dedicated suites for syntax errors, escape sequences, replacements, general patterns, and a PCRE-derived compatibility corpus (pcre_tests.rs), giving unusually broad regression coverage for a regex engine; the codebase is actively maintained with ~11 commits/month and 13 tagged releases. API Design: the public regress::Regex type mirrors familiar regex-crate ergonomics (Regex::new(pattern), .find(), .find_iter()) while accepting JavaScript-flavored flags directly, so developers coming from either Rust’s regex crate or JavaScript’s RegExp can adopt it with only small adjustments for flag semantics.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search