std::match_results<BidirIt,Alloc>::size
來自 cppreference.com
< cpp | regex | match results
size_type size() const noexcept; |
(C++11 起) | |
返回子匹配的數量,即 std::distance(begin(), end())。
如果 *this 不表示成功匹配的結果,則返回 0。
目錄 |
[編輯] 引數
(無)
[編輯] 返回值
子匹配的數量。
[編輯] 複雜度
常數時間。
[編輯] 示例
執行此程式碼
#include <iostream> #include <regex> #include <string> int main() { std::regex re("a(a)*b"); std::string target("aaab"); std::smatch sm; std::cout << sm.size() << '\n'; std::regex_match(target, sm, re); std::cout << sm.size() << '\n'; }
輸出
0 2
[編輯] 參閱
返回子匹配列表開頭的迭代器 (public member function) | |
返回子匹配列表末尾的迭代器 (public member function) |