std::match_results
| Defined in header <regex> |  |  | 
|---|---|---|
| template< class BidirIt, class Alloc = std::allocator<std::sub_match<BidirIt>> > class match_results; | (1) | (since C++11) | 
| namespace pmr { template <class BidirIt> using match_results = std::match_results<BidirIt, std::pmr::polymorphic_allocator< std::sub_match<BidirIt>>>; } | (2) | (since C++17) | 
类模板std::match_results保存表示正则表达式匹配结果的字符序列集合。
这是一个专门的分配器感知容器.。只能默认创建,并从std::regex_iterator,或经std::regex_search或std::regex_match.因为std::match_results托std::sub_matchES,每个迭代器都是一对迭代器,进入匹配的原始字符序列,它将%27s未定义的行为进行检查。std::match_results如果原始字符序列被破坏,或者迭代器由于其他原因而失效。
第一sub_match%28指数0%29match_result始终表示由regex生成的目标序列中的完全匹配,以及后续的匹配。sub_matchES表示与正则表达式中的子表达式按顺序与左括号对应的子表达式匹配。
std::match_results满足常数的要求AllocatorAwareContainer和一个常数SequenceContainer,只是比较函数的语义与容器所需的不同。
类型要求
-Bidirit必须符合双向迭代器的要求。
*。
-分配器必须符合分配器的要求。
专门性
提供了几种常见字符序列类型的专门化:
在标头中定义<regex>
*。
类型定义
STD::cMatch STD::Match[医]结果<Const char%2A>
STD::WcMatch STD::Match[医]结果<Const wchar[医]T型%2A>
STD::SMatch STD::Match[医]结果<std::string::const[医]迭代器>
STD::wsMatch STD::Match[医]结果<std::wstring::const[医]迭代器>
STD::PMR::cMatch%28C++17%29 std::pmr::Match[医]结果<Const char%2A>
std::pmr::wcMatch%28C++17%29 std::pmr::Match[医]结果<Const wchar[医]T型%2A>
性病::PMR::SMatch%28C++17%29 STD::PMR::Match[医]结果<std::string::const[医]迭代器>
std::pmr::wsmatch%28C++17%29 std::pmr::Match[医]结果<std::wstring::const[医]迭代器>
成员类型
| 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> | 
成员函数
| (constructor) | constructs the object (public member function) | 
|---|---|
| (destructor) | destructs the object (public member function) | 
| operator= | assigns the contents (public member function) | 
| get_allocator | returns the associated allocator (public member function) | 
国家
准备检查结果是否可用%28公共成员函数%29
大小
空检查匹配是否成功%28公共成员函数%29
Size返回完全建立的结果状态%28公共成员函数%29中的匹配数。
马克斯[医]Size返回最大可能的子匹配数%28公共成员函数%29。
元素存取
长度返回特定子匹配%28公共成员函数%29的长度。
位置返回特定子匹配%28公共成员函数%29的第一个字符的位置。
返回特定子匹配%28公共成员函数%29的字符序列。
操作者。[]返回指定的子匹配%28公共成员函数%29。
前缀返回目标序列开始和完全匹配开始之间的子序列。28%公共成员职能%29
后缀返回完全匹配结束和目标序列%28公共成员函数%29之间的子序列。
迭代器
初学者将迭代器返回到子匹配列表的开头%28公共成员函数%29。
endcend将迭代器返回到子匹配列表的末尾%28公共成员函数%29。
格式
格式格式匹配输出%28公共成员函数%29的结果
修饰符
交换交换内容%28公共成员函数%29
非会员职能
| operator==operator!= | lexicographically compares the values in the two match result (function template) | 
|---|---|
| std::swap(std::match_results) (C++11) | specializes the std::swap() algorithm (function template) | 
 © cppreference.com在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com

