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 \bare ASCII); every other method mirrors the top-level string API. Group 0 is the whole match; spans are byte offsets.
Structs§
- Capture
Location Matches - Iterator over matches with reusable group slots — from
Regex::captures_read_iter. - Capture
Locations - Reusable capture-slot buffer — drop-in for [
regex::CaptureLocations]. - Capture
Matches - 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 (mirrorsregex::NoExpand). - Regex
- A compiled pattern.
- Regex
Builder - A builder for a
Regexwith readable options — the mirror ofregex::RegexBuilder. - Regex
Set - 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
limitpieces, fromRegex::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::replaceand friends — a&str/Stringtemplate (with$0,$1,$name,${name}expansion and$$for a literal$), aNoExpandliteral, or a closureFnMut(&Captures) -> impl AsRef<str>.