28 Text processing library [text] (original) (raw)
28.6 Regular expressions library [re]
28.6.10 Regular expression algorithms [re.alg]
28.6.10.2 regex_match [re.alg.match]
template<class BidirectionalIterator, class Allocator, class charT, class traits> bool regex_match(BidirectionalIterator first, BidirectionalIterator last, match_results<BidirectionalIterator, Allocator>& m,const basic_regex<charT, traits>& e, regex_constants::match_flag_type flags = regex_constants::match_default);
Effects: Determines whether there is a match between the regular expression e, and all of the character sequence [first, last).
The parameter flags is used to control how the expression is matched against the character sequence.
When determining if there is a match, only potential matches that match the entire character sequence are considered.
Returns true if such a match exists, falseotherwise.
[Example 1: std::regex re("Get|GetValue"); std::cmatch m; regex_search("GetValue", m, re); regex_match ("GetValue", m, re); regex_search("GetValues", m, re); regex_match ("GetValues", m, re); β _end example_]
Postconditions: m.ready() == true in all cases.
If the function returns false, then the effect on parameter m is unspecified except that m.size()returns 0 and m.empty() returns true.
Otherwise the effects on parameter m are given in Table 123.
Table 123 β Effects of regex_match algorithm [tab:re.alg.match]
| πElement | Value |
|---|---|
| πm.size() | 1 + e.mark_count() |
| πm.empty() | false |
| πm.prefix().first | first |
| πm.prefix().second | first |
| πm.prefix().matched | false |
| πm.suffix().first | last |
| πm.suffix().second | last |
| πm.suffix().matched | false |
| πm[0].first | first |
| πm[0].second | last |
| πm[0].matched | true |
| πm[n].first | For all integers 0 < n < m.size(), the start of the sequence that matched sub-expression n. Alternatively, if sub-expression n did not participate in the match, then last. |
| πm[n].second | For all integers 0 < n < m.size(), the end of the sequence that matched sub-expression n. Alternatively, if sub-expression n did not participate in the match, then last. |
| πm[n].matched | For all integers 0 < n < m.size(), true if sub-expression n participated in the match, false otherwise. |
template<class BidirectionalIterator, class charT, class traits> bool regex_match(BidirectionalIterator first, BidirectionalIterator last,const basic_regex<charT, traits>& e, regex_constants::match_flag_type flags = regex_constants::match_default);
Effects: Behaves βas ifβ by constructing an instance ofmatch_results<BidirectionalIterator> what, and then returning the result ofregex_match(first, last, what, e, flags).
template<class charT, class Allocator, class traits> bool regex_match(const charT* str, match_results<const charT*, Allocator>& m,const basic_regex<charT, traits>& e, regex_constants::match_flag_type flags = regex_constants::match_default);
Returns: regex_match(str, str + char_traits<charT>β::βlength(str), m, e, flags).
template<class ST, class SA, class Allocator, class charT, class traits> bool regex_match(const basic_string<charT, ST, SA>& s, match_results<typename basic_string<charT, ST, SA>::const_iterator, Allocator>& m,const basic_regex<charT, traits>& e, regex_constants::match_flag_type flags = regex_constants::match_default);
Returns: regex_match(s.begin(), s.end(), m, e, flags).
template<class charT, class traits> bool regex_match(const charT* str,const basic_regex<charT, traits>& e, regex_constants::match_flag_type flags = regex_constants::match_default);
Returns: regex_match(str, str + char_traits<charT>β::βlength(str), e, flags).
template<class ST, class SA, class charT, class traits> bool regex_match(const basic_string<charT, ST, SA>& s,const basic_regex<charT, traits>& e, regex_constants::match_flag_type flags = regex_constants::match_default);
Returns: regex_match(s.begin(), s.end(), e, flags).