regex_match Function
完全符合規則運算式。
template<class BidIt, class Alloc, class Elem, class RXtraits, class Alloc2>
bool regex_match(BidIt first, Bidit last,
match_results<BidIt, Alloc>& match,
const basic_regex<Elem, RXtraits, Alloc2>& re,
match_flag_type flags = match_default);
template<class BidIt, class Elem, class RXtraits, class Alloc2>
bool regex_match(BidIt first, Bidit last,
const basic_regex<Elem, RXtraits, Alloc2>& re,
match_flag_type flags = match_default);
template<class Elem, class Alloc, class RXtraits, class Alloc2>
bool regex_match(const Elem *ptr,
match_results<const Elem*, Alloc>& match,
const basic_regex<Elem, RXtraits, Alloc2>& re,
match_flag_type flags = match_default);
template<class Elem, class RXtraits, class Alloc2>
bool regex_match(const Elem *ptr,
const basic_regex<Elem, RXtraits, Alloc2>& re,
match_flag_type flags = match_default);
template<class IOtraits, class IOalloc, class Alloc, class Elem, class RXtraits, class Alloc2>
bool regex_match(const basic_string<Elem, IOtraits, IOalloc>& str,
match_results<typename basic_string<Elem, IOtraits, IOalloc>::const_iterator, Alloc>& match,
const basic_regex<Elem, RXtraits, Alloc2>& re,
match_flag_type flags = match_default);
template<class IOtraits, class IOalloc, class Elem, class RXtraits, class Alloc2>
bool regex_match(const basic_string<Elem, IOtraits, IOalloc>& str,
const basic_regex<Elem, RXtraits, Alloc2>& re,
match_flag_type flags = match_default);
參數
BidIt
子相符項目的列舉值型別。Alloc
比對出現配置器類別。Elem
項目的型別來對應。RXtraits
項目特性類別。Alloc2
規則運算式配置器類別。IOtraits
字串類別特性。IOalloc
字串配置器類別。flags
符合的旗標。first
序列開頭來對應。last
序列結尾來對應。match
符合結果。ptr
要啟動的指標來對應序列。re
要比對的規則運算式。str
符合的字串。
備註
,只有在其運算元序列完全相符的規則運算式引數 re,每一個樣板函式傳回 true。 取得物件的 match_results 函式設定其成員反映比對是否成功和,以何種規則運算式的各種擷取群組所擷取的。
範例
// std_tr1__regex__regex_match.cpp
// compile with: /EHsc
#include <regex>
#include <iostream>
int main()
{
const char *first = "abc";
const char *last = first + strlen(first);
std::cmatch mr;
std::regex rx("abc");
std::regex_constants::match_flag_type fl =
std::regex_constants::match_default;
std::cout << "match(f, f+1, \"abc\") == " << std::boolalpha
<< regex_match(first, first + 1, rx, fl) << std::endl;
std::cout << "match(f, l, \"abc\") == " << std::boolalpha
<< regex_match(first, last, mr, rx) << std::endl;
std::cout << " matched: \"" << mr.str() << "\"" << std::endl;
std::cout << "match(\"a\", \"abc\") == " << std::boolalpha
<< regex_match("a", rx) << std::endl;
std::cout << "match(\"abc\", \"abc\") == " << std::boolalpha
<< regex_match("abc", mr, rx) << std::endl;
std::cout << " matched: \"" << mr.str() << "\"" << std::endl;
std::cout << "match(string, \"abc\") == " << std::boolalpha
<< regex_match(std::string("a"), rx) << std::endl;
std::string str("abc");
std::match_results<std::string::const_iterator> mr2;
std::cout << "match(string, \"abc\") == " << std::boolalpha
<< regex_match(str, mr2, rx) << std::endl;
std::cout << " matched: \"" << mr2.str() << "\"" << std::endl;
return (0);
}
需求
標題: <regex>
命名空間: std