Skip to content

Regex, forged in Rust.

Ferroni is a pure-Rust port of the Oniguruma regex engine — the engine behind Ruby, PHP, and TextMate grammars. Full feature parity with the C original. Up to 59x faster on scanner workloads.

2,090
Tests passing
100%
C parity
0.4%
Unsafe code
BSD-2
License

Full compatibility. No compromises.

Ferroni does not wrap Oniguruma. It ports the engine into Rust, keeps the same structure and optimization pipeline, then tunes the runtime path hard.

Built for scanner speed

Up to 59x faster first-match latency. 31x faster full-line tokenization. Tuned for the hot path in syntax highlighters and text scanners.

Full Oniguruma compatibility

Named captures, variable-length lookbehind, conditionals, absent expressions, 886 Unicode properties, subexpression calls. If it works in Oniguruma, it works in Ferroni.

Pure Rust, no C toolchain

cargo add ferroni and build. Cross-compiles to wasm32-unknown-unknown. No node-gyp, no local C compiler. Only 0.4% unsafe code, all documented.

Built-in multi-pattern scanner

Drop-in compatible with vscode-oniguruma. Regex engine and TextMate grammar scanner in a single dependency. Used by Shiki and VS Code.

Measured, not claimed.

Every number comes from battle_bench, a head-to-head benchmark suite running Ferroni against Oniguruma on the same inputs. No cherry-picked subsets.

Syntax Highlighting
Scanner First Match
TypeScript grammar, 279 patterns
59x
faster
Ferroni~425 ns
Oniguruma~25 µs
Syntax Highlighting
Full Line Tokenization
TypeScript, end-to-end
31x
faster
Ferroni~6.9 µs
Oniguruma~217 µs
Syntax Highlighting
CSS Tokenization
Multi-pattern scanner workload
11x
faster
Ferroni~1.3 ms
Oniguruma~14.7 ms
Text Search
Rejection Speed
No match in 50 KB buffer
6x
faster
Ferroni~1.5 µs
Oniguruma~9.2 µs
Text Search
RegSet Multi-Pattern
5 patterns, simultaneous search
3.8x
faster
Ferroni<100 ns
Oniguruma~385 ns
Pattern Matching
Lookaround Combined
Feature most Rust engines skip
3.5x
faster
Ferroni<80 ns
Oniguruma~280 ns

Full benchmark tables and methodology in Benchmark Results

Three lines to your first match

Add Ferroni as a dependency. Write a pattern. Match.

main.rs
use ferroni::prelude::*;

fn main() -> Result<(), RegexError> {
    let re = Regex::new(r"(?<year>\d{4})-(?\u003cmonth\u003e\d{2})")?;

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

The Oniguruma ecosystem, unlocked

Ferroni works wherever Oniguruma does. These projects all depend on Oniguruma’s feature set — and Ferroni covers it completely.

Ruby
Core regex engine
PHP
mbstring module
TextMate
Grammar syntax
jq
Pattern matching
Shiki
Syntax highlighting
VS Code
Token engine

Start building with Ferroni

Full Oniguruma compatibility with dramatically better performance. One dependency. Pure Rust.