Localization library | |||||||||||||||||||||||||
Regular expressions library(C++11) | |||||||||||||||||||||||||
Formatting library(C++20) | |||||||||||||||||||||||||
Null-terminated sequence utilities | |||||||||||||||||||||||||
Byte strings | |||||||||||||||||||||||||
Multibyte strings | |||||||||||||||||||||||||
Wide strings | |||||||||||||||||||||||||
Primitive numeric conversions | |||||||||||||||||||||||||
| |||||||||||||||||||||||||
Text encoding identifications | |||||||||||||||||||||||||
|
Classes | ||||
(C++11) | ||||
(C++11) | ||||
match_results (C++11) | ||||
Algorithms | ||||
(C++11) | ||||
(C++11) | ||||
(C++11) | ||||
Iterators | ||||
(C++11) | ||||
(C++11) | ||||
Exceptions | ||||
(C++11) | ||||
Traits | ||||
(C++11) | ||||
Constants | ||||
(C++11) | ||||
(C++11) | ||||
(C++11) | ||||
Regex Grammar | ||||
(C++11) |
Member functions | ||||
State | ||||
Element access | ||||
Iterators | ||||
Format | ||||
Modifiers | ||||
Non-member functions | ||||
(until C++20) | ||||
Defined in header <regex> | ||
template< class BidirIt, | (1) | (since C++11) |
namespace pmr{ template<class BidirIt> | (2) | (since C++17) |
The class templatestd::match_results
holds a collection of character sequences that represent the result of a regular expression match.
This is a specialized allocator-aware container. It can only be default created, obtained fromstd::regex_iterator, or modified bystd::regex_search orstd::regex_match. Becausestd::match_results
holdsstd::sub_matches, each of which is a pair of iterators into the original character sequence that was matched, it's undefined behavior to examinestd::match_results
if the original character sequence was destroyed or iterators to it were invalidated for other reasons.
The firststd::sub_match (index 0) contained in astd::match_result
always represents the full match within a target sequence made by a regex, and subsequentstd::sub_matches represent sub-expression matches corresponding in sequence to the left parenthesis delimiting the sub-expression in the regex.
std::match_results
meets the requirements of aAllocatorAwareContainer and of aSequenceContainer, except that only copy assignment, move assignment, and operations defined for a constant containers are supported, and that the semantics of comparison functions are different from those required for a container.
Contents |
-BidirIt must meet the requirements ofLegacyBidirectionalIterator. | ||
-Alloc must meet the requirements ofAllocator. |
Several specializations for common character sequence types are provided:
Defined in header <regex> | |
Type | Definition |
std::cmatch | std::match_results<constchar*> |
std::wcmatch | std::match_results<constwchar_t*> |
std::smatch | std::match_results<std::string::const_iterator> |
std::wsmatch | std::match_results<std::wstring::const_iterator> |
std::pmr::cmatch (C++17) | std::pmr::match_results<constchar*> |
std::pmr::wcmatch (C++17) | std::pmr::match_results<constwchar_t*> |
std::pmr::smatch (C++17) | std::pmr::match_results<std::string::const_iterator> |
std::pmr::wsmatch (C++17) | std::pmr::match_results<std::wstring::const_iterator> |
Member type | Definition |
allocator_type | Allocator |
value_type | std::sub_match<BidirIt> |
const_reference | const value_type& |
reference | value_type& |
const_iterator | implementation-defined (depends on the underlying container) |
iterator | const_iterator |
difference_type | std::iterator_traits<BidirIt>::difference_type |
size_type | std::allocator_traits<Alloc>::size_type |
char_type | std::iterator_traits<BidirIt>::value_type |
string_type | std::basic_string<char_type> |
constructs the object (public member function)[edit] | |
destructs the object (public member function)[edit] | |
assigns the contents (public member function)[edit] | |
returns the associated allocator (public member function)[edit] | |
State | |
checks if the results are available (public member function) | |
Size | |
checks whether the match was successful (public member function)[edit] | |
returns the number of matches in a fully-established result state (public member function)[edit] | |
returns the maximum possible number of sub-matches (public member function)[edit] | |
Element access | |
returns the length of the particular sub-match (public member function)[edit] | |
returns the position of the first character of the particular sub-match (public member function)[edit] | |
returns the sequence of characters for the particular sub-match (public member function)[edit] | |
returns specified sub-match (public member function)[edit] | |
returns sub-sequence between the beginning of the target sequence and the beginning of the full match (public member function)[edit] | |
returns sub-sequence between the end of the full match and the end of the target sequence (public member function)[edit] | |
Iterators | |
returns iterator to the beginning of the list of sub-matches (public member function)[edit] | |
returns iterator to the end of the list of sub-matches (public member function)[edit] | |
Format | |
formats match results for output (public member function)[edit] | |
Modifiers | |
swaps the contents (public member function)[edit] |
(removed in C++20) | lexicographically compares the values in the two match result (function template)[edit] |
specializes thestd::swap algorithm (function template)[edit] |