Skip to main content

Crate real_regex

Crate real_regex 

Source
Expand description

Linear-time, ReDoS-safe regular expressions with bounded lookarounds — a drop-in-shaped Rust binding to the REAL C++ engine (via its C ABI). The API mirrors the regex crate; every pattern that compiles matches in time linear in the input, with no backtracking and so no catastrophic blow-up. The engine is strict by design — a construct it cannot run linearly (a backreference, an unbounded lookaround) is rejected at Regex::new, never silently made non-linear.

use real_regex::Regex;
let re = Regex::new(r"(?P<y>\d{4})-(?P<m>\d{2})").unwrap();
let caps = re.captures("2026-07").unwrap();
assert_eq!(&caps["y"], "2026");
assert_eq!(caps.get(2).unwrap().as_str(), "07");

Modules§

bytes
Byte-oriented regular expressions — the mirror of [regex::bytes], matching over &[u8] (which need not be valid UTF-8). Patterns compile in REAL’s raw-byte mode (\w \d \s \b are ASCII); every other method mirrors the top-level string API. Group 0 is the whole match; spans are byte offsets.

Structs§

CaptureLocationMatches
Iterator over matches with reusable group slots — from Regex::captures_read_iter.
CaptureLocations
Reusable capture-slot buffer — drop-in for [regex::CaptureLocations].
CaptureMatches
Iterator over capture groups, from Regex::captures_iter.
Captures
The capture groups of a single match. Group 0 is the whole match.
Match
A single match — one span into the subject (the whole match, or one capture group).
Matches
Iterator over whole-match spans, from Regex::find_iter.
NoExpand
A literal replacement, with no $ expansion (mirrors regex::NoExpand).
Regex
A compiled pattern.
RegexBuilder
A builder for a Regex with readable options — the mirror of regex::RegexBuilder.
RegexSet
A multi-pattern set: which patterns match the subject at least once (which-matched).
Split
Iterator of the pieces between matches, from Regex::split.
SplitN
Iterator of at most limit pieces, from Regex::splitn.

Enums§

Engine
Which engine backs a compiled pattern — observable via Regex::engine.
Error
Why a pattern failed to compile.

Constants§

VERSION
The crate’s version (CalVer, shared with the C++ engine and the Python wheel).

Traits§

Replacer
A replacement value for Regex::replace and friends — a &str/String template (with $0, $1, $name, ${name} expansion and $$ for a literal $), a NoExpand literal, or a closure FnMut(&Captures) -> impl AsRef<str>.