REAL
Regular Expression Algorithmic Library — constexpr C++20 regex
Loading...
Searching...
No Matches
regex_match.hpp File Reference

std::regex-compatibility layer, part 2/3: sub_match, match_results, the shared runner, and the regex_search / regex_match / regex_replace free functions. Included via the std/regex.hpp umbrella. More...

#include "regex_core.hpp"
#include <algorithm>
#include <iterator>
Include dependency graph for regex_match.hpp:

Go to the source code of this file.

Classes

class  real::compat::sub_match< BidirIt >
 A matched sub-expression: a [first, second) range into the searched sequence. More...
 
class  real::compat::match_results< BidirIt, Alloc >
 The result of a match: group sub-matches plus the prefix and suffix. More...
 

Namespaces

namespace  real
 
namespace  real::compat
 
namespace  real::compat::detail
 

Typedefs

using real::compat::ssub_match = sub_match< std::string::const_iterator >
 Sub-match over a std::string.
 
using real::compat::csub_match = sub_match< const char * >
 Sub-match over a C string.
 
using real::compat::wssub_match = sub_match< std::wstring::const_iterator >
 Sub-match over a std::wstring.
 
using real::compat::wcsub_match = sub_match< const wchar_t * >
 Sub-match over a wide C string.
 
using real::compat::smatch = match_results< std::string::const_iterator >
 Match over a std::string.
 
using real::compat::cmatch = match_results< const char * >
 Match over a C string.
 
using real::compat::wsmatch = match_results< std::wstring::const_iterator >
 Match over a std::wstring (always std).
 
using real::compat::wcmatch = match_results< const wchar_t * >
 Match over a wide C string (always std).
 

Functions

template<typename BidirIt >
bool real::compat::operator== (const sub_match< BidirIt > &lhs, const typename sub_match< BidirIt >::string_type &rhs)
 Equality against an owned string (the common std::sub_match comparison).
 
template<typename BidirIt >
bool real::compat::operator== (const typename sub_match< BidirIt >::string_type &lhs, const sub_match< BidirIt > &rhs)
 
template<typename BidirIt >
bool real::compat::operator== (const sub_match< BidirIt > &lhs, const sub_match< BidirIt > &rhs)
 
bool real::compat::detail::real_honors (regex_constants::match_flag_type mf) noexcept
 Whether real can honor the requested match flags, so the operation may stay on it.
 
bool real::compat::detail::replace_stays_real (regex_constants::match_flag_type f) noexcept
 Whether regex_replace can run its substitution on real. The real expander honors only format_first_only / format_no_copy (plus the match_any hint); ANY other bit — a constraining match flag (not_bol, continuous, …) OR format_sed (POSIX syntax) — would be silently ignored by the ECMAScript expander, so the whole substitution routes to std. (This subsumes the explicit format_sed screen; $0 stays content-based.)
 
std::regex_constants::match_flag_type real::compat::detail::to_std_match (regex_constants::match_flag_type f) noexcept
 Maps compat match/format flags to std::regex_constants — exhaustive (the std path).
 
template<typename BidirIt , typename CharT , typename Traits >
bool real::compat::detail::run (BidirIt first, BidirIt last, match_results< BidirIt > &m, const basic_regex< CharT, Traits > &re, bool anchored, regex_constants::match_flag_type mf)
 Runs the active backend over [first, last) and fills m. anchored selects whole-sequence match (regex_match) vs leftmost search (regex_search). A constraining match flag (see real_honors) routes to std even for a real-backed pattern.
 
template<typename BidirIt , typename CharT , typename Traits >
bool real::compat::detail::run_nocapture (BidirIt first, BidirIt last, const basic_regex< CharT, Traits > &re, bool anchored, regex_constants::match_flag_type mf)
 Backend run without capturing (no match_results to fill).
 
template<typename BidirIt , typename CharT , typename Traits >
bool real::compat::regex_search (BidirIt first, BidirIt last, match_results< BidirIt > &m, const basic_regex< CharT, Traits > &re, regex_constants::match_flag_type flags=regex_constants::match_default)
 Leftmost search of [first, last) (Python re.search / std::regex_search).
 
template<typename CharT , typename Traits >
bool real::compat::regex_search (const std::basic_string< CharT > &s, match_results< typename std::basic_string< CharT >::const_iterator > &m, const basic_regex< CharT, Traits > &re, regex_constants::match_flag_type flags=regex_constants::match_default)
 
template<typename CharT , typename Traits >
bool real::compat::regex_search (const CharT *s, match_results< const CharT * > &m, const basic_regex< CharT, Traits > &re, regex_constants::match_flag_type flags=regex_constants::match_default)
 
template<typename BidirIt , typename CharT , typename Traits >
bool real::compat::regex_search (BidirIt first, BidirIt last, const basic_regex< CharT, Traits > &re, regex_constants::match_flag_type flags=regex_constants::match_default)
 
template<typename CharT , typename Traits >
bool real::compat::regex_search (const std::basic_string< CharT > &s, const basic_regex< CharT, Traits > &re, regex_constants::match_flag_type flags=regex_constants::match_default)
 
template<typename CharT , typename Traits >
bool real::compat::regex_search (const CharT *s, const basic_regex< CharT, Traits > &re, regex_constants::match_flag_type flags=regex_constants::match_default)
 
template<typename BidirIt , typename CharT , typename Traits >
bool real::compat::regex_match (BidirIt first, BidirIt last, match_results< BidirIt > &m, const basic_regex< CharT, Traits > &re, regex_constants::match_flag_type flags=regex_constants::match_default)
 Match of the entire [first, last) (Python re.fullmatch / std::regex_match).
 
template<typename CharT , typename Traits >
bool real::compat::regex_match (const std::basic_string< CharT > &s, match_results< typename std::basic_string< CharT >::const_iterator > &m, const basic_regex< CharT, Traits > &re, regex_constants::match_flag_type flags=regex_constants::match_default)
 
template<typename CharT , typename Traits >
bool real::compat::regex_match (const CharT *s, match_results< const CharT * > &m, const basic_regex< CharT, Traits > &re, regex_constants::match_flag_type flags=regex_constants::match_default)
 
template<typename BidirIt , typename CharT , typename Traits >
bool real::compat::regex_match (BidirIt first, BidirIt last, const basic_regex< CharT, Traits > &re, regex_constants::match_flag_type flags=regex_constants::match_default)
 
template<typename CharT , typename Traits >
bool real::compat::regex_match (const std::basic_string< CharT > &s, const basic_regex< CharT, Traits > &re, regex_constants::match_flag_type flags=regex_constants::match_default)
 
template<typename CharT , typename Traits >
bool real::compat::regex_match (const CharT *s, const basic_regex< CharT, Traits > &re, regex_constants::match_flag_type flags=regex_constants::match_default)
 
template<typename CharT , typename Traits >
bool real::compat::regex_search (const std::basic_string< CharT > &&, match_results< typename std::basic_string< CharT >::const_iterator > &, const basic_regex< CharT, Traits > &)=delete
 
template<typename CharT , typename Traits >
bool real::compat::regex_search (const std::basic_string< CharT > &&, match_results< typename std::basic_string< CharT >::const_iterator > &, const basic_regex< CharT, Traits > &, regex_constants::match_flag_type)=delete
 
template<typename CharT , typename Traits >
bool real::compat::regex_match (const std::basic_string< CharT > &&, match_results< typename std::basic_string< CharT >::const_iterator > &, const basic_regex< CharT, Traits > &)=delete
 
template<typename CharT , typename Traits >
bool real::compat::regex_match (const std::basic_string< CharT > &&, match_results< typename std::basic_string< CharT >::const_iterator > &, const basic_regex< CharT, Traits > &, regex_constants::match_flag_type)=delete
 
template<typename RealMatch >
void real::compat::detail::expand_format (std::string &out, const RealMatch &m, std::string_view fmt, std::string_view text, std::size_t prefix_start)
 Appends one match's ECMAScript-expanded replacement.
 
template<typename CharT , typename Traits >
std::basic_string< CharT > real::compat::regex_replace (const std::basic_string< CharT > &s, const basic_regex< CharT, Traits > &re, const std::basic_string< CharT > &fmt, regex_constants::match_flag_type flags=regex_constants::format_default)
 Replaces matches of re in s with the ECMAScript-formatted fmt.
 
template<typename CharT , typename Traits >
std::basic_string< CharT > real::compat::regex_replace (const std::basic_string< CharT > &s, const basic_regex< CharT, Traits > &re, const CharT *fmt, regex_constants::match_flag_type flags=regex_constants::format_default)
 regex_replace overload for a C-string format.
 
template<typename OutputIt , typename BidirIt , typename CharT , typename Traits >
OutputIt real::compat::regex_replace (OutputIt out, BidirIt first, BidirIt last, const basic_regex< CharT, Traits > &re, const std::basic_string< CharT > &fmt, regex_constants::match_flag_type flags=regex_constants::format_default)
 regex_replace writing to an output iterator (std parity).
 

Detailed Description

std::regex-compatibility layer, part 2/3: sub_match, match_results, the shared runner, and the regex_search / regex_match / regex_replace free functions. Included via the std/regex.hpp umbrella.

Definition in file regex_match.hpp.