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);
Requires: ТипBidirectionalIterator должен удовлетворять требованиям аBidirectional Iterator.
Effects: Определяет, есть ли совпадение между регулярным выражениемeи всей последовательностью символов[first, last). Параметрflags используется для управления тем, как выражение сопоставляется с последовательностью символов. При определении совпадения учитываются только потенциальные совпадения, соответствующие всей последовательности символов. Возвращает,true если такое совпадение существует, вfalse противном случае. [ Example:
std::regex re("Get|GetValue"); std::cmatch m; regex_search("GetValue", m, re); // returns true, and m[0] contains "Get" regex_match ("GetValue", m, re); // returns true, and m[0] contains "GetValue" regex_search("GetValues", m, re); // returns true, and m[0] contains "Get" regex_match ("GetValues", m, re); // returns false
— end example ]
Элемент | Ценить |
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 | Для всех целых чисел0 < n < m.size()- начало последовательности, соответствующей подвыражениюn. В качестве альтернативы, если подвыражениеn не участвовало в сопоставлении, тогдаlast. |
m[n].second | Для всех целых чисел0 < n < m.size()- конец последовательности, соответствующей подвыражениюn. В качестве альтернативы, если подвыражениеn не участвовало в сопоставлении, тогдаlast. |
m[n].matched | Для всех целых чисел0 < n < m.size(),true еслиn в совпадении участвовало подвыражение, вfalse противном случае. |
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: Ведет себя «как будто», создавая экземпляр match_results<BidirectionalIterator> what, а затем возвращая результат regex_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);
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);
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);
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);
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);
Requires: ТипBidirectionalIterator должен соответствовать требованиям аBidirectional Iterator.
Effects: Определяет, есть ли внутри подпоследовательность,[first, last) которая соответствует регулярному выражениюe. Параметрflags используется для управления тем, как выражение сопоставляется с последовательностью символов. Возвращает,true если такая последовательность существует, вfalse противном случае.
Элемент | Ценить |
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 | Начало последовательности символов, соответствующих регулярному выражению. |
m[0].second | Конец последовательности символов, соответствующей регулярному выражению. |
m[0].matched | true |
m[n].first | Для всех целых чисел0 < n < m.size()- начало последовательности, соответствующей подвыражениюn. В качестве альтернативы, если подвыражениеn не участвовало в сопоставлении, тогдаlast. |
m[n].second | Для всех целых чисел0 < n < m.size()- конец последовательности, соответствующей подвыражениюn. В качестве альтернативы, если подвыражениеn не участвовало в сопоставлении, тогдаlast . |
m[n].matched | Для всех целых чисел0 < n < m.size(),true еслиn в совпадении участвовало подвыражение, вfalse противном случае. |
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);
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);
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: Ведет себя «как будто», создавая объектwhat типаmatch_results<BidirectionalIterator> и возвращая его regex_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);
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);
template <class OutputIterator, class BidirectionalIterator,
class traits, class charT, class ST, class SA>
OutputIterator
regex_replace(OutputIterator out,
BidirectionalIterator first, BidirectionalIterator last,
const basic_regex<charT, traits>& e,
const basic_string<charT, ST, SA>& fmt,
regex_constants::match_flag_type flags = regex_constants::match_default);
template <class OutputIterator, class BidirectionalIterator, class traits, class charT>
OutputIterator
regex_replace(OutputIterator out,
BidirectionalIterator first, BidirectionalIterator last,
const basic_regex<charT, traits>& e,
const charT* fmt,
regex_constants::match_flag_type flags = regex_constants::match_default);
Effects: Создаетregex_iterator объект,i как если бы
regex_iterator<BidirectionalIterator, charT, traits> i(first, last, e, flags)
и используетсяi для перечисления всех совпаденийm типаmatch_results<BidirectionalIterator> , встречающихся в последовательности[first, last). Если таких совпадений не найдено и !(flags & regex_constants::format_no_copy), то вызывает
out = copy(first, last, out)
Если какие-либо совпадения найдены, то для каждого такого совпадения:
Если!(flags & regex_constants::format_no_copy)звонит
out = copy(m.prefix().first, m.prefix().second, out)
Затем звонит
out = m.format(out, fmt, flags)
для первой формы функции и
out = m.format(out, fmt, fmt + char_traits<charT>::length(fmt), flags)
для второго.
Наконец, если такое совпадение найдено и!(flags & regex_constants::format_no_copy)вызывается
out = copy(last_m.suffix().first, last_m.suffix().second, out)
гдеlast_m копия последнего найденного совпадения. Еслиflags & regex_constants::format_first_only не ноль, то заменяется только первое найденное совпадение.
template <class traits, class charT, class ST, class SA, class FST, class FSA>
basic_string<charT, ST, SA>
regex_replace(const basic_string<charT, ST, SA>& s,
const basic_regex<charT, traits>& e,
const basic_string<charT, FST, FSA>& fmt,
regex_constants::match_flag_type flags = regex_constants::match_default);
template <class traits, class charT, class ST, class SA>
basic_string<charT, ST, SA>
regex_replace(const basic_string<charT, ST, SA>& s,
const basic_regex<charT, traits>& e,
const charT* fmt,
regex_constants::match_flag_type flags = regex_constants::match_default);
Effects: Создает пустую строкуresult типаbasic_string<charT, ST, SA> и вызывает:
regex_replace(back_inserter(result), s.begin(), s.end(), e, fmt, flags);
template <class traits, class charT, class ST, class SA>
basic_string<charT>
regex_replace(const charT* s,
const basic_regex<charT, traits>& e,
const basic_string<charT, ST, SA>& fmt,
regex_constants::match_flag_type flags = regex_constants::match_default);
template <class traits, class charT>
basic_string<charT>
regex_replace(const charT* s,
const basic_regex<charT, traits>& e,
const charT* fmt,
regex_constants::match_flag_type flags = regex_constants::match_default);
Effects: Создает пустую строкуresult типаbasic_string<charT> и вызывает:
regex_replace(back_inserter(result), s, s + char_traits<charT>::length(s), e, fmt, flags);