REAL
Regular Expression Algorithmic Library — constexpr C++20 regex
Loading...
Searching...
No Matches
real::basic_regex< Storage > Class Template Reference

A compiled regular expression, parameterized on its storage policy. More...

#include <real.hpp>

Public Types

using result_type = basic_match_result< typename Storage::slot_storage >
 This regex's match-result type.
 

Public Member Functions

constexpr basic_regex (std::string_view pattern, flags compile_flags=flags::none)
 Compiles pattern at run time (the real::regex constructor).
 
constexpr basic_regex ()=default
 Default constructor for the stateless compile-time storage (static_regex).
 
constexpr result_type match (std::string_view text) const
 Match anchored at the start of text (Python re.match).
 
constexpr result_type fullmatch (std::string_view text) const
 Match the entire text (Python re.fullmatch).
 
constexpr result_type search (std::string_view text) const
 Leftmost match anywhere in text (Python re.search).
 
constexpr result_type match (std::string_view text, std::size_t pos, std::size_t endpos=npos) const
 Region-aware match: anchored at pos within text[0:endpos] (Python re.match with pos / endpos). Byte offsets; pos is not a slice (see run\A fails at pos > 0); endpos defaults to the end of text.
 
constexpr result_type fullmatch (std::string_view text, std::size_t pos, std::size_t endpos=npos) const
 Region-aware fullmatch: the whole region [pos, endpos) must match.
 
constexpr result_type search (std::string_view text, std::size_t pos, std::size_t endpos=npos) const
 Region-aware search: leftmost match within [pos, endpos).
 
constexpr result_type match (const char *text) const
 match overload for string literals.
 
constexpr result_type fullmatch (const char *text) const
 fullmatch overload for string literals.
 
constexpr result_type search (const char *text) const
 search overload for string literals.
 
constexpr basic_match_range< Storage > find_iter (std::string_view text) const &
 Lazy range over all non-overlapping matches (Python re.finditer).
 
constexpr basic_match_range< Storage > find_iter (const char *text) const &
 find_iter overload for string literals.
 
constexpr basic_match_range< Storage > find_iter (std::string_view text, std::size_t pos, std::size_t endpos=npos) const &
 Region-aware find_iter: iterate matches within [pos, endpos) (Python finditer with pos / endpos). endpos truncates the subject to a view so iteration stops at it; pos is the start, not a slice (see run). Byte offsets; endpos defaults to the end of text.
 
constexpr basic_match_range< Storage > find_iter_longest (std::string_view text, std::size_t pos=0, std::size_t endpos=npos) const &
 Experimental leftmost-**longest** find_iter: iterate matches with POSIX (leftmost-longest) bounds rather than the default leftmost-first — the iterator twin of search_longest, sharing its prototype status (the match_semantics arc is not yet stable). Region semantics match find_iterendpos truncates the subject to a view, pos is the start (not a slice). Byte offsets; captures are the winning thread's, not POSIX submatch. Every fast path is bypassed.
 
basic_match_range< Storage > find_iter_longest (std::string_view, std::size_t, std::size_t) const &&=delete
 Deleted: find_iter_longest on a temporary regex would dangle.
 
basic_match_range< Storage > find_iter (std::string_view text) const &&=delete
 Deleted: find_iter on a temporary regex would dangle.
 
basic_match_range< Storage > find_iter (const char *text) const &&=delete
 Deleted: find_iter on a temporary regex would dangle.
 
basic_match_range< Storage > find_iter (std::string_view text, std::size_t, std::size_t=npos) const &&=delete
 Deleted: region find_iter on a temporary regex would dangle.
 
constexpr std::vector< result_typefind_all (std::string_view text) const &
 All matches, eagerly (like Python re.findall but full results).
 
constexpr std::vector< result_typefind_all (const char *text) const &
 find_all overload for string literals.
 
std::vector< result_typefind_all (std::string_view text) const &&=delete
 Deleted: find_all on a temporary regex would dangle.
 
std::vector< result_typefind_all (const char *text) const &&=delete
 Deleted: find_all on a temporary regex would dangle.
 
constexpr std::string replace (std::string_view text, std::string_view replacement, std::size_t max_count=0) const
 Replaces matches in text (Python re.sub).
 
constexpr std::vector< std::string_view > split (std::string_view text, std::size_t max_splits=0) const
 Splits text on matches (Python re.split).
 
constexpr std::vector< std::string_view > split (const char *text, std::size_t max_splits=0) const
 split overload for string literals.
 
result_type match (const std::string &&text) const =delete
 Deleted: temporary text would dangle.
 
result_type fullmatch (const std::string &&text) const =delete
 Deleted: temporary text would dangle.
 
result_type search (const std::string &&text) const =delete
 Deleted: temporary text would dangle.
 
result_type match (const std::string &&text, std::size_t, std::size_t=npos) const =delete
 Deleted: temporary text would dangle.
 
result_type fullmatch (const std::string &&text, std::size_t, std::size_t=npos) const =delete
 Deleted: temporary text would dangle.
 
result_type search (const std::string &&text, std::size_t, std::size_t=npos) const =delete
 Deleted: temporary text would dangle.
 
basic_match_range< Storage > find_iter (const std::string &&text) const &=delete
 Deleted: temporary text would dangle.
 
basic_match_range< Storage > find_iter (const std::string &&text, std::size_t, std::size_t=npos) const &=delete
 Deleted: temporary text would dangle.
 
std::vector< result_typefind_all (const std::string &&text) const &=delete
 Deleted: temporary text would dangle.
 
std::vector< std::string_view > split (const std::string &&text, std::size_t max_splits=0) const =delete
 Deleted: temporary text would dangle.
 
constexpr std::string_view pattern () const
 Returns the pattern text this regex was compiled from.
 
constexpr flags compile_flags () const
 Returns the effective flags (constructor flags merged with a (?ims) prefix).
 
constexpr std::size_t group_count () const
 Returns the number of capturing groups (excluding group 0).
 
constexpr detail::program_view raw_program () const
 The raw compiled program, for embedders (advanced).
 
constexpr bool has_first_byte_set () const noexcept
 Whether first-byte filtering is useful for this pattern.
 
constexpr std::optional< unsigned char > unique_first_byte () const noexcept
 The single byte every non-empty match must begin with, if unique.
 
constexpr bool may_start_with (unsigned char byte) const noexcept
 Whether a non-empty match can begin with byte (sound, conservative).
 
constexpr std::size_t group_index (std::string_view name) const
 Resolves a group name to its number.
 
constexpr std::vector< std::pair< std::string_view, std::size_t > > named_groups () const
 All named groups as (name, number) pairs, in declaration order.
 
result_type search_longest (std::string_view text) const
 EXPERIMENTAL, opt-in: a single leftmost-**longest** search (POSIX / RE2 set_longest_match), the default leftmost-first semantics left untouched. Among matches at the leftmost start it returns the longest; a lazy quantifier therefore behaves greedily, and captures are the leftmost-first thread's at that longest bound (not POSIX submatch). Runs on the general Pike loop (the first-match DFA / inner-literal fast paths are bypassed). A prototype for the match_semantics arc — not yet a stable API. Its iteration twin is find_iter_longest.
 
result_type search_longest (std::string_view text, std::size_t pos, std::size_t endpos=npos) const
 Region-aware form of search_longest — leftmost-longest search within [pos, endpos). pos is the start (not a slice, per run); endpos truncates the subject. Byte offsets.
 

Private Member Functions

constexpr std::string_view name_of (const detail::named_group &named_group) const
 Returns its name, sliced from the pattern text.
 
constexpr void expand_replacement (std::string &out, const result_type &match, std::string_view replacement) const
 Appends replacement to out, substituting group references.
 
constexpr result_type run (std::string_view text, detail::run_mode mode) const
 Runs a single match attempt from offset 0 (backs match/search/fullmatch).
 
constexpr result_type run (std::string_view text, std::size_t pos, std::size_t endpos, detail::run_mode mode, match_semantics sem=match_semantics::first) const
 Region-aware single attempt: match over text[0:endpos] starting at pos.
 

Private Attributes

Storage program_
 The storage policy holding the compiled program.
 

Detailed Description

template<typename Storage>
class real::basic_regex< Storage >

A compiled regular expression, parameterized on its storage policy.

Storage owns the program; matching allocates only per-run scratch — and nothing at all when the storage is compile-time. Use the real::regex and real::static_regex aliases rather than this template directly.

Template Parameters
Storagereal::detail::dynamic_storage or real::detail::static_storage.

Definition at line 467 of file real.hpp.

Member Typedef Documentation

◆ result_type

template<typename Storage >
using real::basic_regex< Storage >::result_type = basic_match_result<typename Storage::slot_storage>

This regex's match-result type.

Definition at line 471 of file real.hpp.

Constructor & Destructor Documentation

◆ basic_regex() [1/2]

template<typename Storage >
constexpr real::basic_regex< Storage >::basic_regex ( std::string_view  pattern,
flags  compile_flags = flags::none 
)
inlineexplicitconstexpr

Compiles pattern at run time (the real::regex constructor).

Parameters
[in]patternThe pattern text.
[in]compile_flagsOptional flags (merged with a leading (?ims)).
Exceptions
real::regex_erroron an invalid or over-limit pattern.

Definition at line 479 of file real.hpp.

◆ basic_regex() [2/2]

template<typename Storage >
constexpr real::basic_regex< Storage >::basic_regex ( )
constexprdefault

Default constructor for the stateless compile-time storage (static_regex).

Member Function Documentation

◆ compile_flags()

template<typename Storage >
constexpr flags real::basic_regex< Storage >::compile_flags ( ) const
inlineconstexpr

Returns the effective flags (constructor flags merged with a (?ims) prefix).

Definition at line 796 of file real.hpp.

◆ expand_replacement()

template<typename Storage >
constexpr void real::basic_regex< Storage >::expand_replacement ( std::string &  out,
const result_type match,
std::string_view  replacement 
) const
inlineconstexprprivate

Appends replacement to out, substituting group references.

Strict like Python: an invalid or out-of-range reference is an error.

Parameters
[in,out]outThe output string to append to.
[in]matchThe match supplying the captured groups.
[in]replacementThe replacement template ($$, $&, $1, ${name}).
Exceptions
real::regex_erroron a malformed or out-of-range reference.

Definition at line 922 of file real.hpp.

◆ find_all() [1/5]

template<typename Storage >
constexpr std::vector< result_type > real::basic_regex< Storage >::find_all ( const char *  text) const &
inlineconstexpr

find_all overload for string literals.

Parameters
[in]textNUL-terminated text.
Returns
The results.

Definition at line 681 of file real.hpp.

◆ find_all() [2/5]

template<typename Storage >
std::vector< result_type > real::basic_regex< Storage >::find_all ( const char *  text) const &&
delete

Deleted: find_all on a temporary regex would dangle.

◆ find_all() [3/5]

template<typename Storage >
std::vector< result_type > real::basic_regex< Storage >::find_all ( const std::string &&  text) const &
delete

Deleted: temporary text would dangle.

◆ find_all() [4/5]

template<typename Storage >
constexpr std::vector< result_type > real::basic_regex< Storage >::find_all ( std::string_view  text) const &
inlineconstexpr

All matches, eagerly (like Python re.findall but full results).

Lvalue-only for the same reason as find_iter (results reference this regex's name table).

Parameters
[in]textThe subject text (must outlive the results).
Returns
A vector of match results.

Definition at line 667 of file real.hpp.

◆ find_all() [5/5]

template<typename Storage >
std::vector< result_type > real::basic_regex< Storage >::find_all ( std::string_view  text) const &&
delete

Deleted: find_all on a temporary regex would dangle.

◆ find_iter() [1/8]

template<typename Storage >
constexpr basic_match_range< Storage > real::basic_regex< Storage >::find_iter ( const char *  text) const &
inlineconstexpr

find_iter overload for string literals.

Parameters
[in]textNUL-terminated text.
Returns
The range.

Definition at line 604 of file real.hpp.

◆ find_iter() [2/8]

template<typename Storage >
basic_match_range< Storage > real::basic_regex< Storage >::find_iter ( const char *  text) const &&
delete

Deleted: find_iter on a temporary regex would dangle.

◆ find_iter() [3/8]

template<typename Storage >
basic_match_range< Storage > real::basic_regex< Storage >::find_iter ( const std::string &&  text) const &
delete

Deleted: temporary text would dangle.

◆ find_iter() [4/8]

template<typename Storage >
basic_match_range< Storage > real::basic_regex< Storage >::find_iter ( const std::string &&  text,
std::size_t  ,
std::size_t  = npos 
) const &
delete

Deleted: temporary text would dangle.

◆ find_iter() [5/8]

template<typename Storage >
constexpr basic_match_range< Storage > real::basic_regex< Storage >::find_iter ( std::string_view  text) const &
inlineconstexpr

Lazy range over all non-overlapping matches (Python re.finditer).

Only callable on an lvalue regex: calling on a temporary would dangle in a C++20 range-for (the range initializer's temporaries die before the loop body), so that misuse is a compile error (deleted rvalue overloads).

Parameters
[in]textThe subject text (must outlive the range).
Returns
A basic_match_range usable directly in a range-for.

Definition at line 594 of file real.hpp.

◆ find_iter() [6/8]

template<typename Storage >
basic_match_range< Storage > real::basic_regex< Storage >::find_iter ( std::string_view  text) const &&
delete

Deleted: find_iter on a temporary regex would dangle.

◆ find_iter() [7/8]

template<typename Storage >
constexpr basic_match_range< Storage > real::basic_regex< Storage >::find_iter ( std::string_view  text,
std::size_t  pos,
std::size_t  endpos = npos 
) const &
inlineconstexpr

Region-aware find_iter: iterate matches within [pos, endpos) (Python finditer with pos / endpos). endpos truncates the subject to a view so iteration stops at it; pos is the start, not a slice (see run). Byte offsets; endpos defaults to the end of text.

Definition at line 615 of file real.hpp.

◆ find_iter() [8/8]

template<typename Storage >
basic_match_range< Storage > real::basic_regex< Storage >::find_iter ( std::string_view  text,
std::size_t  ,
std::size_t  = npos 
) const &&
delete

Deleted: region find_iter on a temporary regex would dangle.

◆ find_iter_longest() [1/2]

template<typename Storage >
constexpr basic_match_range< Storage > real::basic_regex< Storage >::find_iter_longest ( std::string_view  text,
std::size_t  pos = 0,
std::size_t  endpos = npos 
) const &
inlineconstexpr

Experimental leftmost-**longest** find_iter: iterate matches with POSIX (leftmost-longest) bounds rather than the default leftmost-first — the iterator twin of search_longest, sharing its prototype status (the match_semantics arc is not yet stable). Region semantics match find_iterendpos truncates the subject to a view, pos is the start (not a slice). Byte offsets; captures are the winning thread's, not POSIX submatch. Every fast path is bypassed.

Definition at line 630 of file real.hpp.

◆ find_iter_longest() [2/2]

template<typename Storage >
basic_match_range< Storage > real::basic_regex< Storage >::find_iter_longest ( std::string_view  ,
std::size_t  ,
std::size_t   
) const &&
delete

Deleted: find_iter_longest on a temporary regex would dangle.

◆ fullmatch() [1/5]

template<typename Storage >
constexpr result_type real::basic_regex< Storage >::fullmatch ( const char *  text) const
inlineconstexpr

fullmatch overload for string literals.

Parameters
[in]textNUL-terminated text.
Returns
The result.

Definition at line 569 of file real.hpp.

◆ fullmatch() [2/5]

template<typename Storage >
result_type real::basic_regex< Storage >::fullmatch ( const std::string &&  text) const
delete

Deleted: temporary text would dangle.

◆ fullmatch() [3/5]

template<typename Storage >
result_type real::basic_regex< Storage >::fullmatch ( const std::string &&  text,
std::size_t  ,
std::size_t  = npos 
) const
delete

Deleted: temporary text would dangle.

◆ fullmatch() [4/5]

template<typename Storage >
constexpr result_type real::basic_regex< Storage >::fullmatch ( std::string_view  text) const
inlineconstexpr

Match the entire text (Python re.fullmatch).

Parameters
[in]textThe subject text (must outlive the result).
Returns
The match result.

Definition at line 507 of file real.hpp.

◆ fullmatch() [5/5]

template<typename Storage >
constexpr result_type real::basic_regex< Storage >::fullmatch ( std::string_view  text,
std::size_t  pos,
std::size_t  endpos = npos 
) const
inlineconstexpr

Region-aware fullmatch: the whole region [pos, endpos) must match.

Definition at line 537 of file real.hpp.

◆ group_count()

template<typename Storage >
constexpr std::size_t real::basic_regex< Storage >::group_count ( ) const
inlineconstexpr

Returns the number of capturing groups (excluding group 0).

Definition at line 804 of file real.hpp.

◆ group_index()

template<typename Storage >
constexpr std::size_t real::basic_regex< Storage >::group_index ( std::string_view  name) const
inlineconstexpr

Resolves a group name to its number.

Parameters
[in]nameThe group name.
Returns
The group number, or real::npos if unknown.

Definition at line 873 of file real.hpp.

◆ has_first_byte_set()

template<typename Storage >
constexpr bool real::basic_regex< Storage >::has_first_byte_set ( ) const
inlineconstexprnoexcept

Whether first-byte filtering is useful for this pattern.

true iff every non-empty match provably begins with a byte from a known set, so may_start_with can reject positions. false when a zero-length match is possible (or the set is empty) — then may_start_with is true for every byte and the filter buys nothing. This is the same set the engine's own prefilter uses, exposed for embedders (e.g. a lexer's rule dispatch).

Returns
true if the first-byte set is usable.

Definition at line 833 of file real.hpp.

◆ match() [1/5]

template<typename Storage >
constexpr result_type real::basic_regex< Storage >::match ( const char *  text) const
inlineconstexpr

match overload for string literals.

Parameters
[in]textNUL-terminated text.
Returns
The result.

Definition at line 559 of file real.hpp.

◆ match() [2/5]

template<typename Storage >
result_type real::basic_regex< Storage >::match ( const std::string &&  text) const
delete

Deleted: temporary text would dangle.

◆ match() [3/5]

template<typename Storage >
result_type real::basic_regex< Storage >::match ( const std::string &&  text,
std::size_t  ,
std::size_t  = npos 
) const
delete

Deleted: temporary text would dangle.

◆ match() [4/5]

template<typename Storage >
constexpr result_type real::basic_regex< Storage >::match ( std::string_view  text) const
inlineconstexpr

Match anchored at the start of text (Python re.match).

Parameters
[in]textThe subject text (must outlive the result).
Returns
The match result (test with matched() / operator bool).

Definition at line 497 of file real.hpp.

◆ match() [5/5]

template<typename Storage >
constexpr result_type real::basic_regex< Storage >::match ( std::string_view  text,
std::size_t  pos,
std::size_t  endpos = npos 
) const
inlineconstexpr

Region-aware match: anchored at pos within text[0:endpos] (Python re.match with pos / endpos). Byte offsets; pos is not a slice (see run\A fails at pos > 0); endpos defaults to the end of text.

Definition at line 527 of file real.hpp.

◆ may_start_with()

template<typename Storage >
constexpr bool real::basic_regex< Storage >::may_start_with ( unsigned char  byte) const
inlineconstexprnoexcept

Whether a non-empty match can begin with byte (sound, conservative).

A false result is a guarantee: no non-empty match of this pattern begins with byte. A true result is a conservative superset — it does not promise a match actually starts there. When first-byte filtering is not usable (has_first_byte_set is false, i.e. an empty match is possible), this returns true for every byte, so it is safe to use on its own.

Parameters
[in]byteThe candidate leading byte.
Returns
false only when byte can never start a non-empty match.

Definition at line 862 of file real.hpp.

◆ name_of()

template<typename Storage >
constexpr std::string_view real::basic_regex< Storage >::name_of ( const detail::named_group named_group) const
inlineconstexprprivate

Returns its name, sliced from the pattern text.

Parameters
[in]named_groupA named group.
Returns
Its name, sliced from the pattern text.

Definition at line 906 of file real.hpp.

◆ named_groups()

template<typename Storage >
constexpr std::vector< std::pair< std::string_view, std::size_t > > real::basic_regex< Storage >::named_groups ( ) const
inlineconstexpr

All named groups as (name, number) pairs, in declaration order.

Returns
The list of named groups.

Definition at line 888 of file real.hpp.

◆ pattern()

template<typename Storage >
constexpr std::string_view real::basic_regex< Storage >::pattern ( ) const
inlineconstexpr

Returns the pattern text this regex was compiled from.

Definition at line 788 of file real.hpp.

◆ raw_program()

template<typename Storage >
constexpr detail::program_view real::basic_regex< Storage >::raw_program ( ) const
inlineconstexpr

The raw compiled program, for embedders (advanced).

Lets an embedder (e.g. the Python binding) drive detail::pike_vm with caller-owned reusable scratch. Valid as long as this regex is alive.

Returns
A non-owning detail::program_view.

Definition at line 817 of file real.hpp.

◆ replace()

template<typename Storage >
constexpr std::string real::basic_regex< Storage >::replace ( std::string_view  text,
std::string_view  replacement,
std::size_t  max_count = 0 
) const
inlineconstexpr

Replaces matches in text (Python re.sub).

The replacement may reference groups: $$ → '$', $& or $0 → whole match, $1 …, and ${name}. Returns an owning string, so a temporary text is fine here.

Parameters
[in]textThe subject text.
[in]replacementThe replacement template.
[in]max_countMaximum replacements (0 = all).
Returns
The resulting string.
Exceptions
real::regex_erroron a malformed group reference in replacement.

Definition at line 708 of file real.hpp.

◆ run() [1/2]

template<typename Storage >
constexpr result_type real::basic_regex< Storage >::run ( std::string_view  text,
detail::run_mode  mode 
) const
inlineconstexprprivate

Runs a single match attempt from offset 0 (backs match/search/fullmatch).

Parameters
[in]textThe subject text.
[in]modeThe anchoring mode.
Returns
The match result.

Definition at line 988 of file real.hpp.

◆ run() [2/2]

template<typename Storage >
constexpr result_type real::basic_regex< Storage >::run ( std::string_view  text,
std::size_t  pos,
std::size_t  endpos,
detail::run_mode  mode,
match_semantics  sem = match_semantics::first 
) const
inlineconstexprprivate

Region-aware single attempt: match over text[0:endpos] starting at pos.

pos is the VM start offset, not a slice — zero-width assertions still see the absolute position, so \A and ^ (non-multiline) fail at pos > 0, matching Python re. endpos truncates the subject to a view (no copy), so $ / \Z treat it as the end. endpos is clamped to the text length; pos > endpos yields no match. Capture offsets are absolute byte offsets in text.

Parameters
[in]textThe full subject (offsets are relative to it; must outlive the result).
[in]posByte offset to start matching at.
[in]endposByte offset of the exclusive region end; npos = end of text.
[in]modeThe anchoring mode.
[in]semMatch semantics: leftmost-first (default) or the experimental leftmost-longest.
Returns
The match result, with offsets absolute in text.

Definition at line 1010 of file real.hpp.

◆ search() [1/5]

template<typename Storage >
constexpr result_type real::basic_regex< Storage >::search ( const char *  text) const
inlineconstexpr

search overload for string literals.

Parameters
[in]textNUL-terminated text.
Returns
The result.

Definition at line 579 of file real.hpp.

◆ search() [2/5]

template<typename Storage >
result_type real::basic_regex< Storage >::search ( const std::string &&  text) const
delete

Deleted: temporary text would dangle.

◆ search() [3/5]

template<typename Storage >
result_type real::basic_regex< Storage >::search ( const std::string &&  text,
std::size_t  ,
std::size_t  = npos 
) const
delete

Deleted: temporary text would dangle.

◆ search() [4/5]

template<typename Storage >
constexpr result_type real::basic_regex< Storage >::search ( std::string_view  text) const
inlineconstexpr

Leftmost match anywhere in text (Python re.search).

Parameters
[in]textThe subject text (must outlive the result).
Returns
The match result.

Definition at line 517 of file real.hpp.

◆ search() [5/5]

template<typename Storage >
constexpr result_type real::basic_regex< Storage >::search ( std::string_view  text,
std::size_t  pos,
std::size_t  endpos = npos 
) const
inlineconstexpr

Region-aware search: leftmost match within [pos, endpos).

Definition at line 547 of file real.hpp.

◆ search_longest() [1/2]

template<typename Storage >
result_type real::basic_regex< Storage >::search_longest ( std::string_view  text) const
inline

EXPERIMENTAL, opt-in: a single leftmost-**longest** search (POSIX / RE2 set_longest_match), the default leftmost-first semantics left untouched. Among matches at the leftmost start it returns the longest; a lazy quantifier therefore behaves greedily, and captures are the leftmost-first thread's at that longest bound (not POSIX submatch). Runs on the general Pike loop (the first-match DFA / inner-literal fast paths are bypassed). A prototype for the match_semantics arc — not yet a stable API. Its iteration twin is find_iter_longest.

Definition at line 1038 of file real.hpp.

◆ search_longest() [2/2]

template<typename Storage >
result_type real::basic_regex< Storage >::search_longest ( std::string_view  text,
std::size_t  pos,
std::size_t  endpos = npos 
) const
inline

Region-aware form of search_longest — leftmost-longest search within [pos, endpos). pos is the start (not a slice, per run); endpos truncates the subject. Byte offsets.

Definition at line 1047 of file real.hpp.

◆ split() [1/3]

template<typename Storage >
constexpr std::vector< std::string_view > real::basic_regex< Storage >::split ( const char *  text,
std::size_t  max_splits = 0 
) const
inlineconstexpr

split overload for string literals.

Parameters
[in]textNUL-terminated text.
[in]max_splitsMax splits.
Returns
The pieces.

Definition at line 765 of file real.hpp.

◆ split() [2/3]

template<typename Storage >
std::vector< std::string_view > real::basic_regex< Storage >::split ( const std::string &&  text,
std::size_t  max_splits = 0 
) const
delete

Deleted: temporary text would dangle.

◆ split() [3/3]

template<typename Storage >
constexpr std::vector< std::string_view > real::basic_regex< Storage >::split ( std::string_view  text,
std::size_t  max_splits = 0 
) const
inlineconstexpr

Splits text on matches (Python re.split).

Each capturing group's text is inserted after its split (an unset group yields an empty view, where Python would use None).

Parameters
[in]textThe subject text (must outlive the returned views).
[in]max_splitsMaximum splits (0 = split everywhere).
Returns
The pieces, with captured separators interleaved.

Definition at line 738 of file real.hpp.

◆ unique_first_byte()

template<typename Storage >
constexpr std::optional< unsigned char > real::basic_regex< Storage >::unique_first_byte ( ) const
inlineconstexprnoexcept

The single byte every non-empty match must begin with, if unique.

Returns
The byte when the pattern has exactly one possible first byte (e.g. a plain literal like if / def); std::nullopt for zero or several.

Definition at line 844 of file real.hpp.

Member Data Documentation

◆ program_

template<typename Storage >
Storage real::basic_regex< Storage >::program_
private

The storage policy holding the compiled program.

Definition at line 899 of file real.hpp.


The documentation for this class was generated from the following file: