|
REAL
Regular Expression Algorithmic Library — constexpr C++20 regex
|
real::compat::re2 — an RE2-compatible drop-in, the RE2 class surface.
More...
#include <real/version.hpp>#include <cstdint>#include <cstdio>#include <mutex>#include <optional>#include <string>#include <string_view>#include <utility>#include <vector>#include <real/real.hpp>#include <real/regex_set.hpp>#include "arg.hpp"#include "flavor.hpp"Classes | |
| class | real::compat::re2::RE2 |
RE2-compatible drop-in for RE2. Backed by real::regex — linear-time, ReDoS-safe. More... | |
| class | real::compat::re2::RE2::Options |
RE2-compatible construction options. Mirrors real RE2's RE2::Options field-for-field (names, defaults); see the file-level doc comment for which fields this layer honors. More... | |
| class | real::compat::re2::RE2::Set |
RE2::Set: Add patterns, Compile once, then Match repeatedly, on real::regex_set::which(). The anchor is applied by wrapping each pattern, real::regex_set being unanchored. More... | |
| struct | real::compat::re2::LazyRE2 |
RE2's LazyRE2: a pattern compiled on first use, once, thread-safely – static LazyRE2 re = {"a+"}; then RE2::FullMatch(text, *re). An aggregate, as RE2's, so the members are public; only pattern_ and options_ are meant to be set, by that brace initialisation. More... | |
Namespaces | |
| namespace | real |
| REAL's public API: real::regex, real::static_regex, real::flags and the match/iterator types built on them. | |
| namespace | real::compat |
Drop-in replacements for <regex>, backed by REAL's linear-time engine where it can serve the pattern and by std::regex otherwise, never by a silent divergence. | |
| namespace | real::compat::re2 |
| Drop-in replacement for RE2's API surface, on REAL's engine. | |
real::compat::re2 — an RE2-compatible drop-in, the RE2 class surface.
Names follow RE2's re2.h exactly (FullMatch, set_longest_match, ANCHOR_START, …). This wraps real::regex and real::regex_set: no RE2 dependency at run time.
REAL compiles everything RE2 compiles, plus bounded lookarounds, possessive quantifiers and wider Unicode properties (\p{sc=…}, \p{Emoji}, …). It is deliberately stricter in two places: duplicate group names (match-by-name would be ambiguous) and surrogate code points in \x{…}, \u, \U, \N (not Unicode scalars). Both surface as ok() == false.
RE2's reading of the syntax. \w \d \s are ASCII, \b \B read ASCII word characters, [[:alpha:]] is a POSIX class, $ without (?m) is the end of the text, and a class member folds before it is negated ((?i)\W leaves out the Kelvin sign): see re2/flavor.hpp. GlobalReplace walks as RE2's does. Case folding keeps REAL's tables, which are Python's: under (?i), İ and ı (U+0130, U+0131) go with i and I, where RE2 keeps them apart.
No fallback, no exceptions. A pattern or option this layer cannot honor is rejected as RE2 rejects a syntax error: ok() == false, with error() saying why.
Scope. RE2's default mode: UTF-8, no posix_syntax. posix_syntax, Latin-1, never_nl and never_capture are rejected at construction (ErrorUnsupported), never ignored; perl_classes, word_boundary and one_line are inert, as in RE2 outside posix_syntax. longest_match is honored by every unanchored search (PartialMatch, FindAndConsume, Replace, GlobalReplace); captures inside an ambiguous alternation then carry RE2's own non-POSIX caveat.
**\C is accepted**, as in RE2: exactly one byte, possibly mid-codepoint. Safe here because this API is byte-offset, as RE2's is; REAL's char-offset surfaces keep it behind flags::bytes.