6.7 KiB
[re.alg.search]
28 Text processing library [text]
28.6 Regular expressions library [re]
28.6.10 Regular expression algorithms [re.alg]
28.6.10.3 regex_search [re.alg.search]
template<class BidirectionalIterator, class Allocator, class charT, class traits> bool regex_search(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);
Preconditions: BidirectionalIterator modelsbidirectional_iterator ([iterator.concept.bidir]).
Effects: Determines whether there is some sub-sequence within [first, last) that matches the regular expression e.
The parameter flags is used to control how the expression is matched against the character sequence.
Returns true if such a sequence exists, false otherwise.
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 124.
Table 124 — Effects of regex_search algorithm [tab:re.alg.search]
| ð Element |
Value |
|---|---|
| ð m.size() |
1 + e.mark_count() |
| ð m.empty() |
false |
| ð m.prefix().first |
first |
| ð m.prefix().second |
m[0].first |
| ð m.prefix().matched |
m.prefix().first != m.prefix().second |
| ð m.suffix().first |
m[0].second |
| ð m.suffix().second |
last |
| ð m.suffix().matched |
m.suffix().first != m.suffix().second |
| ð m[0].first |
The start of the sequence of characters that matched the regular expression |
| ð m[0].second |
The end of the sequence of characters that matched the regular expression |
| ð 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 charT, class Allocator, class traits> bool regex_search(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_search(str, str + char_traits::length(str), m, e, flags).
template<class ST, class SA, class Allocator, class charT, class traits> bool regex_search(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_search(s.begin(), s.end(), m, e, flags).
template<class BidirectionalIterator, class charT, class traits> bool regex_search(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 object what of type match_results and returningregex_search(first, last, what, e, flags).
template<class charT, class traits> bool regex_search(const charT* str, const basic_regex<charT, traits>& e, regex_constants::match_flag_type flags = regex_constants::match_default);
Returns: regex_search(str, str + char_traits::length(str), e, flags).
template<class ST, class SA, class charT, class traits> bool regex_search(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_search(s.begin(), s.end(), e, flags).