定义于头文件
<regex>
|
||
template<
class BidirIt, |
(1) | (C++11 起) |
namespace pmr {
template <class BidirIt> |
(2) | (C++17 起) |
类模板 std::match_results 保有表示正则表达式匹配结果的字符序列汇集。
这是特殊的具分配器容器。它只能默认创建、从std::regex_iterator 获得,或通过 std::regex_search 或 std::regex_match 修改。 std::match_results
保有 std::sub_match ,它们每个都是一对指向匹配的原初字符序列中的迭代器,故若原初字符序列被销毁,或指向它的迭代器因另外的原因非法化,则检验 std::match_results
是未定义行为。
match_result
中所含的首个 sub_match
(下标 0 )始终表示 regex 所做的目标序列内的完整匹配,而后继的 sub_match
表示按顺序对应分隔正则表达式中子表达式的左括号的子表达式匹配
std::match_results
满足常具分配器容器 (AllocatorAwareContainer
) 和常顺序容器 (SequenceContainer
) 的要求,除了比较函数的语义有别于对容器所要求者。
目录 |
-
BidirIt 必须满足 BidirectionalIterator 的要求。
|
||
-
Alloc 必须满足 Allocator 的要求。
|
提供几个对常用字符类型的特化:
定义于头文件
<regex> |
|
类型 | 定义 |
std::cmatch
|
std::match_results<const char*> |
std::wcmatch
|
std::match_results<const wchar_t*> |
std::smatch
|
std::match_results<std::string::const_iterator> |
std::wsmatch
|
std::match_results<std::wstring::const_iterator> |
std::pmr::cmatch (C++17)
|
std::pmr::match_results<const char*> |
std::pmr::wcmatch (C++17)
|
std::pmr::match_results<const wchar_t*> |
std::pmr::smatch (C++17)
|
std::pmr::match_results<std::string::const_iterator> |
std::pmr::wsmatch (C++17)
|
std::pmr::match_results<std::wstring::const_iterator> |
成员类型 | 定义 |
allocator_type
|
Allocator |
value_type
|
std::sub_match<BidirIt> |
const_reference
|
const value_type& |
reference
|
value_type& |
const_iterator
|
实现定义(依赖于底层容器) |
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> |
构造对象 (公开成员函数) |
|
析构对象 (公开成员函数) |
|
赋值内容 (公开成员函数) |
|
返回关联的分配器 (公开成员函数) |
|
状态 |
|
检查结果是否合法 (公开成员函数) |
|
大小 |
|
检查匹配是否成功 (公开成员函数) |
|
返回完全建立的结果状态中的匹配数 (公开成员函数) |
|
返回子匹配的最大可能数量 (公开成员函数) |
|
元素访问 |
|
返回特定子匹配的长度 (公开成员函数) |
|
返回特定子匹配首字符的位置 (公开成员函数) |
|
返回特定子匹配的字符序列 (公开成员函数) |
|
返回指定的子匹配 (公开成员函数) |
|
返回目标序列起始和完整匹配起始之间的子序列。 (公开成员函数) |
|
返回完整匹配结尾和目标序列结尾之间的子序列 (公开成员函数) |
|
迭代器 |
|
返回指向子匹配列表起始的迭代器 (公开成员函数) |
|
返回指向子匹配列表末尾的迭代器 (公开成员函数) |
|
格式 |
|
为输出格式化匹配结果 (公开成员函数) |
|
修改器 |
|
交换内容 (公开成员函数) |
以字典序比较两个匹配结果的值 (函数模板) |
|
(C++11)
|
特化 std::swap() 算法 (函数模板) |