|
|
| basic_regex ()=default |
| | An empty pattern on the std backend — the variant's first alternative default-constructs.
|
| |
| | basic_regex (const CharT *pattern, flag_type f=regex_constants::ECMAScript, policy pol=policy::strict) |
| | Compiles pattern from a C string.
|
| |
| | basic_regex (const string_type &pattern, flag_type f=regex_constants::ECMAScript, policy pol=policy::strict) |
| | Compiles pattern from an owned string.
|
| |
| | basic_regex (const CharT *pattern, std::size_t len, flag_type f=regex_constants::ECMAScript, policy pol=policy::strict) |
| | Compiles the first len characters of pattern, which need not be NUL-terminated.
|
| |
| template<typename It > |
| | basic_regex (It begin, It end, flag_type f=regex_constants::ECMAScript, policy pol=policy::strict) |
| | Compiles the pattern in [begin, end).
|
| |
| std::size_t | mark_count () const noexcept |
| | Number of marked sub-expressions (excluding group 0), as std::basic_regex.
|
| |
| flag_type | flags () const noexcept |
| | The flags this regex was built with.
|
| |
| void | swap (basic_regex &other) noexcept |
| | Exchanges engines, flags, policy and cached state with other.
|
| |
| bool | uses_real () const noexcept |
| | True if this regex is backed by the real engine (vs the std fallback).
|
| |
| bool | uses_fallback () const noexcept |
| | True if this regex fell back to std::regex (a policy::fallback regex on an ineligible pattern) — so this pattern is not linear-time / ReDoS-safe. Always false under strict.
|
| |
| compat::policy | policy () const noexcept |
| | The drop-in policy this regex was constructed with.
|
| |
| const std::variant< std::basic_regex< CharT, Traits >, real::regex > & | engine () const noexcept |
| | Access the active backend (engine-facing; used by the free functions).
|
| |
| bool | nullable () const noexcept |
| | Whether the pattern can match the empty string (real's empty_match_possible hint).
|
| |
| bool | posix_longest () const noexcept |
| | Whether this is a POSIX pattern routed to REAL: search/match must use leftmost-**longest** bounds (the POSIX semantics), not the default leftmost-first. Set for any of the five POSIX grammars once detail::translate_posix has translated it onto REAL; a pattern that stays on the std backend leaves it false, since std applies POSIX semantics itself.
|
| |
| bool | uses_real_traversal () const noexcept |
| | Whether replace/iterate run on the real traversal (real-backed AND non-nullable AND no nullable captured-repeat group). A nullable pattern delegates replace/iterate to std (the empty-match traversal differs; and iterating a nullable pattern whose per-position match cost is O(n) is O(n²) on any linear engine, so routing it buys correctness but not a linear guarantee — see the nullable note in COMPATIBILITY.md). A pattern with a capturing group that is nullable under a quantifier ((ab|)+a) is itself non-nullable as a whole, but real's last-consuming-iteration capture (RE2/Rust/Go lineage) diverges from an ECMAScript backtracker's extra empty final iteration on that GROUP's span — so it routes too, for the same reason: regex_search/match are unaffected (see the nullable-loop group-capture section of COMPATIBILITY.md — the search residue is intentional, not an oversight).
|
| |
| const std::basic_regex< CharT, Traits > & | std_engine () const |
| | The std::regex for the std / lazy-std path (built once on demand for a real-backed pattern reached via a constraining flag / nullable replace-iterate / $0/sed replace).
|
| |
|
|
std::variant< std::basic_regex< CharT, Traits >, real::regex > | engine_ |
| | Whichever backend compiled this pattern; see uses_real and uses_fallback.
|
| |
|
string_type | pattern_ |
| | Original pattern (for the lazy std build).
|
| |
|
flag_type | flags_ {regex_constants::ECMAScript} |
| | Syntax options it was compiled with (flags).
|
| |
|
std::size_t | mark_count_ {} |
| | Capturing groups excluding the whole match (mark_count).
|
| |
|
bool | nullable_ {} |
| | empty_match_possible (real-backed).
|
| |
|
bool | nullable_captured_repeat_ {} |
| | nullable_captured_repeat (real-backed) — a nullable capturing group under a quantifier; see uses_real_traversal.
|
| |
|
bool | posix_longest_ {} |
| | A POSIX grammar translated onto REAL: search uses leftmost-longest bounds.
|
| |
|
std::optional< std::basic_regex< CharT, Traits > > | lazy_std_ |
| | Lazy std for nullable replace/iterate.
|
| |
|
compat::policy | policy_ {policy::strict} |
| | strict rejects ineligible, fallback delegates to std.
|
| |
template<typename CharT = char, typename Traits = std::regex_traits<CharT>>
class real::compat::basic_regex< CharT, Traits >
A std::basic_regex-compatible pattern, backed by real where proven, else std.
- Template Parameters
-
| CharT | Character type (char; other types route straight to std). |
| Traits | Regex traits (std parity). |
template<typename CharT = char, typename Traits = std::regex_traits<CharT>>
Whether the pattern can match the empty string (real's empty_match_possible hint).
Empty-match traversal (replace / iterate) follows Python's advance rules in real, which differ from ECMAScript. So a nullable real-backed pattern routes those operations to a lazily built std::regex (std_engine) — per operation, not at construction, so search/match keep real's linear-time guarantee even on nullable-ReDoS patterns like (a*)*.
- Returns
true if it is nullable; regex_replace then routes to std, whose empty-match traversal differs from REAL's Python-lineage one.
template<typename CharT = char, typename Traits = std::regex_traits<CharT>>
The std::regex for the std / lazy-std path (built once on demand for a real-backed pattern reached via a constraining flag / nullable replace-iterate / $0/sed replace).
Thread-safe: std::regex guarantees concurrent const operations on one object are safe, but this builds lazy_std_ (a mutable member) on demand. A function-local static build mutex serialises the build (and the read is taken under the same lock), so the guarantee holds for nullable AND non-nullable real-backed patterns. std::once_flag would be lighter but is non-copyable, and basic_regex must stay copyable (std::regex is); a static mutex keeps the value semantics defaulted. The build is per operation, cold relative to matching.
- Returns
- The wrapped
std::basic_regex; compiling one on demand if this pattern is real-backed.
template<typename CharT = char, typename Traits = std::regex_traits<CharT>>
Whether replace/iterate run on the real traversal (real-backed AND non-nullable AND no nullable captured-repeat group). A nullable pattern delegates replace/iterate to std (the empty-match traversal differs; and iterating a nullable pattern whose per-position match cost is O(n) is O(n²) on any linear engine, so routing it buys correctness but not a linear guarantee — see the nullable note in COMPATIBILITY.md). A pattern with a capturing group that is nullable under a quantifier ((ab|)+a) is itself non-nullable as a whole, but real's last-consuming-iteration capture (RE2/Rust/Go lineage) diverges from an ECMAScript backtracker's extra empty final iteration on that GROUP's span — so it routes too, for the same reason: regex_search/match are unaffected (see the nullable-loop group-capture section of COMPATIBILITY.md — the search residue is intentional, not an oversight).
- Returns
true for a real-backed, non-nullable pattern.