ferroni 2.2.4

Oniguruma's regex engine in pure Rust: full Oniguruma syntax, a vscode-oniguruma-compatible TextMate scanner, no C toolchain
Documentation

Part of Ferramenta, a family of Rust tools.

Ferroni — Oniguruma regex in pure Rust

Powered by Sebastian Software crates.io docs.rs CI Coverage gate at least 87 percent MSRV 1.94 License

Oniguruma-compatible regex engine. Ferroni runs Oniguruma's full syntax in Rust, including look-behind, backreferences and recursion, and ships the scanner that TextMate syntax highlighters drive. Cargo builds it like any other crate, WebAssembly included, with no C compiler and no bindgen.

Why Ferroni

Oniguruma ended; the engine goes on. Oniguruma matches the patterns in every TextMate grammar, in PHP's mbstring and in jq. Its C project closed in April 2025. Ferroni continues the engine in memory-safe Rust, ported function by function, and passes all 2,974 UTF-8 tests of the C original.

Only a JIT is faster. Once a pattern is compiled, Ferroni matches 2.7–3.4× faster than C Oniguruma, and it generates no machine code at runtime. Of the engines measured on regex tasks from Django, Rails, WordPress and other projects, only PCRE2's JIT is faster. C still compiles patterns faster, so a pattern used once favors C. The benchmark summary gives the method; the full results are in the repository.

It runs the patterns regex rejects. Rust's regex crate leaves out look-around and backreferences to guarantee linear time. Ferroni runs them as Oniguruma does, in all twelve of its syntax modes, and is the only Rust engine with every feature in the feature matrix. For untrusted patterns, that linear-time guarantee keeps regex the safer choice.

The scanner highlighters expect, in safe Rust. VS Code and Shiki highlight code with TextMate grammars written for Oniguruma. Ferroni's Scanner keeps vscode-oniguruma's API, UTF-16 offsets included, and Ferriki runs on it. C Oniguruma fixed five memory-safety CVEs in 2019; Ferroni's engine is safe Rust, with 10 unsafe sites left, all linking parse-tree nodes, none in buffer or string code.

Explore Ferroni → — examples, compatibility evidence, benchmarks and a Scanner walkthrough.

Quick start

cargo add ferroni
use ferroni::prelude::*;

fn main() -> Result<(), RegexError> {
    // A look-behind and named groups: Oniguruma syntax, a familiar API.
    let re = Regex::new(r"(?<=Date: )(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})")?;

    let caps = re.captures("Date: 2026-02-12").unwrap();
    assert_eq!(caps.get(0).unwrap().as_str(), "2026-02-12");
    assert_eq!(caps.name("year").unwrap().as_str(), "2026");
    Ok(())
}

Scope

Ferroni covers ASCII and UTF-8, two of Oniguruma's 29 encodings, and leaves out the POSIX and GNU APIs. It backtracks like C Oniguruma, so give searches over untrusted input a time or retry limit. On wasm32-unknown-unknown, the browser target, use a retry limit; that target has no clock for a time limit. See compatibility and untrusted input.

Documentation

Project status and contributing

Ferroni is feature-complete and maintained. No feature work is planned; bug fixes, Unicode updates, toolchain upkeep and security fixes continue. See the project status for the maintenance scope.

CONTRIBUTING.md covers builds, tests and benchmarks; pull requests keep the structural parity with C Oniguruma that the port is built on. Report vulnerabilities privately as described in SECURITY.md.

Acknowledgments and license

Built on K. Kosako's Oniguruma and Microsoft's vscode-oniguruma Scanner API and tests. Ferroni is an independent continuation and is not affiliated with or endorsed by Oniguruma's original author.

BSD-2-Clause, inherited from the Oniguruma source this port is based on.

More from Ferramenta

Ferramenta — A family of Rust tools.

Engines

Tool Job
ferriki Shiki-compatible syntax highlighting
ferromark Markdown to HTML, sanitized by default
ferrolex Spell checking for text and code
ferrocat Translation catalog engine
ferralk Glob matching and parallel filesystem walking
ferrugo PDF previews for untrusted files

Applications

Tool Job
palamedes Internationalization for TypeScript applications
dalo Your team's agent setup, versioned like code