Part of Ferramenta, a family of Rust tools.
Ferroni — Oniguruma regex in pure Rust
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
use *;
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
- Getting started — captures, iteration, options, errors and the Scanner API.
- API reference — every public type and function.
- Regex benchmarks — the results, original patterns, input sources, API profiles and comparison rules.
- Migrating to 2.0 — breaking changes with before and after code.
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 |