ferroni 2.2.1

Oniguruma's regex engine in pure Rust: full Oniguruma syntax, a vscode-oniguruma-compatible TextMate scanner, no C toolchain
Documentation
<!-- This file is generated by mdtheme. Edit README.md.src instead. -->

Part of [Ferramenta](https://ferramenta.dev), a family of Rust tools.

# Ferroni — Oniguruma regex in pure Rust

[![Powered by Sebastian Software](https://img.shields.io/badge/Powered_by-Sebastian_Software-005164?style=flat)](https://oss.sebastian-software.com) [![crates.io](https://img.shields.io/crates/v/ferroni?style=flat-square&logo=rust&label=crates.io)](https://crates.io/crates/ferroni)
[![docs.rs](https://img.shields.io/docsrs/ferroni?style=flat-square&logo=docsdotrs&label=docs.rs)](https://docs.rs/ferroni)
[![CI](https://img.shields.io/github/actions/workflow/status/sebastian-software/ferroni/ci.yml?branch=main&style=flat-square&logo=github&label=CI)](https://github.com/sebastian-software/ferroni/actions)
[![Coverage gate at least 87 percent](https://img.shields.io/badge/coverage%20gate-%E2%89%A5%2087%25-blue?style=flat-square)](https://github.com/sebastian-software/ferroni/blob/main/.github/workflows/ci.yml)
[![MSRV 1.94](https://img.shields.io/badge/MSRV-1.94-blue?style=flat-square&logo=rust)](CONTRIBUTING.md#getting-started)
[![License](https://img.shields.io/badge/license-BSD--2--Clause-blue?style=flat-square)](https://github.com/sebastian-software/ferroni/blob/main/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](https://ferroni.dev/perf/regex-workloads) compares
selected syntax across the measured library configurations.

**[Explore Ferroni →](https://ferroni.dev)** — matching examples, compatibility
evidence, benchmarks from real projects and a separate TextMate Scanner walkthrough.

## Quick start

```bash
cargo add ferroni
```

```rust
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](https://ferroni.dev/guide/compatibility)
and [untrusted input](https://ferroni.dev/guide/untrusted-input).

When your patterns fit Rust's [`regex`](https://crates.io/crates/regex)
crate, prefer its guaranteed linear-time matching.

## Performance

The [regex benchmarks](https://ferroni.dev/perf/regex-workloads) 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]https://ferroni.dev/guide/getting-started — captures, iteration, options, errors and the Scanner API.
- [API reference]https://docs.rs/ferroni — every public type and function.
- [Regex benchmarks]https://ferroni.dev/perf/regex-workloads — the results, original patterns, input sources, API profiles and comparison rules.
- [Migrating to 2.0]https://ferroni.dev/guide/migrating-to-2 — 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](https://ferroni.dev/#project-status) for
maintenance scope and contribution opportunities.

[CONTRIBUTING.md](CONTRIBUTING.md) covers builds, tests and benchmarks;
[architecture decisions](https://ferroni.dev/adr/001-one-to-one-parity-with-c-original)
define the port's constraints. Report vulnerabilities privately as described
in [SECURITY.md](SECURITY.md).

## Acknowledgments and license

Built on [K. Kosako's Oniguruma](https://github.com/kkos/oniguruma) and
Microsoft's [vscode-oniguruma](https://github.com/microsoft/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](LICENSE), inherited from the Oniguruma source this port is
based on.

### <a href="https://ferramenta.dev"><img src="https://raw.githubusercontent.com/sebastian-software/ferramenta/main/app/assets/brand/logo-light.svg" width="24" height="24" alt="" /> More from Ferramenta</a>

[Ferramenta](https://ferramenta.dev) — A family of Rust tools.

**Engines**

| Tool | Job |
| --- | --- |
| [ferriki]https://ferriki.dev | Shiki-compatible syntax highlighting |
| [ferromark]https://ferromark.dev | Markdown to HTML, sanitized by default |
| [ferrolex]https://github.com/sebastian-software/ferrolex | Spell checking for text and code |
| [ferrocat]https://ferrocat.dev | Translation catalog engine |
| [ferralk]https://github.com/sebastian-software/ferralk | Glob matching and parallel filesystem walking |
| [ferrugo]https://github.com/sebastian-software/ferrugo | PDF previews for untrusted files |

**Applications**

| Tool | Job |
| --- | --- |
| [palamedes]https://palamedes.dev | Internationalization for TypeScript applications |
| [dalo]https://dalo.sh | Your team's agent setup, versioned like code |

---

<p align="center">
  <a href="https://oss.sebastian-software.com"><img src="https://raw.githubusercontent.com/sebastian-software/oss.sebastian-software.com/main/app/assets/logo-software.svg" alt="Sebastian Software" width="160" /></a><br />
  TypeScript, React &amp; Rust consulting<br />
  Experts in Agentic Software Development<br />
  <a href="https://sebastian-software.de">Work with us</a> · <a href="https://oss.sebastian-software.com">More open source</a>
</p>

<p align="center">Copyright &copy; 2026 Sebastian Software GmbH</p>