ferroni 2.2.1

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

Match, extract and replace text with Oniguruma patterns in pure Rust. Ferroni ports Oniguruma's parser, compiler and optimizer line by line, verifies UTF-8 behavior against the upstream test suite, and adds an idiomatic Rust API. No C compiler or bindgen required.

Use it when your patterns need lookaround, backreferences or subexpression calls, or to replace C Oniguruma in a Rust application. The TextMate Scanner API is also available for grammar consumers such as Ferriki.

Ferroni includes Oniguruma's absent repeaters and recursion-level backreferences, alongside Unicode grapheme matching with \X. PCRE2 also supports lookaround, backreferences and recursion, but uses C and a different regex dialect. Choose Ferroni when your application needs Oniguruma pattern behavior with a Rust-only build. The feature matrix compares selected syntax across the measured library configurations.

Explore Ferroni → — matching examples, compatibility evidence, benchmarks from real projects and a separate TextMate 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 and safety

Ferroni supports ASCII and UTF-8. Other encodings and the POSIX/GNU APIs are outside its scope. It uses backtracking: set timeouts and retry limits for untrusted patterns or input. See compatibility and untrusted input.

When your patterns fit Rust's regex crate, prefer its guaranteed linear-time matching.

Performance

The regex benchmarks compare patterns and test inputs from real projects, including Django, Fluent Bit, Rails and WordPress. Preparing a regex, its first use and repeated use are measured separately on ARM64/macOS and x86-64/Linux.

Ferroni's standard API takes less time than C Oniguruma for repeated use in this corpus's aggregate on both platforms, and no case favors C. PCRE2 JIT is faster in most source-backed reuse cases and in the aggregate, while Ferroni leads in a few; on Rust regex's smaller supported subset, Ferroni takes less time in the aggregate. The tables include cases that favor each engine, unsupported patterns and inconclusive results. Ferroni's fallible API is a separate profile because its match-workspace allocation affects reuse costs.

These measurements cover isolated regex steps. TextMate Scanner calls and Ferriki's complete highlighting are separate workloads.

Documentation

Project status and contributing

Ferroni is feature-complete for its scope and maintained, with no feature work planned. Bug fixes, Unicode updates, toolchain upkeep and security fixes continue. See the project status for maintenance scope and contribution opportunities.

CONTRIBUTING.md covers builds, tests and benchmarks; architecture decisions define the port's constraints. 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