Part of Ferramenta, a family of Rust tools.
Ferroni — Oniguruma regex in pure Rust
Bring your Oniguruma patterns to Rust.
Keep the look-behind, backreferences and recursion your patterns rely on,
with a familiar Regex API and a TextMate scanner built for syntax
highlighters. Cargo handles the build, including WebAssembly. No C compiler,
no bindgen, just Rust.
Quick start
use *;
That's a look-behind and three named captures, ready to use in your Rust project. Compile once, then reuse the pattern across your searches.
| What are you building? | Start here |
|---|---|
| Matching, extraction or replacement | Getting started |
| A tokenizer or TextMate highlighter | Scanner guide |
An application moving from regex or onig |
API mapping and default differences |
Why Ferroni
Give your patterns room to work. Look-around, backreferences, recursive
subexpressions and all twelve Oniguruma syntax modes are included. Ferroni
is the only Rust engine among those checked with every feature in the
feature matrix.
When you need linear-time matching for user-supplied patterns, Rust's
regex crate is a great fit.
Serious speed for patterns you reuse. In the published regex workloads, Ferroni matches 2.5–3.3× faster than C Oniguruma in the family-weighted aggregate after compilation, without generating machine code at runtime. The tasks come from Django, Rails, WordPress and other projects. Results vary by task. C still compiles patterns faster in the aggregate, so check first-use costs when you rarely reuse a pattern. See the benchmark summary and full results for the measured workloads, platforms and tradeoffs.
Build the highlighter you have in mind. Ferroni's Scanner follows vscode-oniguruma's scanning model, including UTF-16 offsets for editor integrations. It finds the next match across a set of patterns; your TextMate runtime handles grammar rules and scopes. Ferriki builds a Shiki-compatible highlighter on it.
An established engine, a Rust future. Oniguruma's C project closed in April 2025. Ferroni continues it, ported function by function, and passes all 2,974 upstream UTF-8 tests. Buffer and string processing use safe Rust. The 10 unsafe sites are confined to links between parse-tree nodes.
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
- Getting started — your first match, captures, replacement, options and errors.
- Scanner guide — tokenization loops, UTF-16 positions and shared compiled patterns.
- API reference — every public type and function.
- Regex benchmarks — the speed summary, source projects, method and feature matrix.
- Benchmark results — per-platform aggregates, with every case and timing in
publication.jsonand tiktoken pre-tokenization inadditional_results. - Migrating to 2.0 — breaking changes with before and after code.
Project status and contributing
Ferroni is feature-complete and maintained: the engine is ready, and the upkeep continues. Bug fixes, Unicode updates, toolchain upkeep and security fixes are in scope; new features are not planned. 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 |