std::match_results<BidirIt,Alloc>::size
From cppreference.com
< cpp | regex | match results
| size_type size() const noexcept; |
(C++11以降) | |
サブマッチの数を返します。つまり、std::distance(begin(), end()) です。
成功したマッチの結果を表していない場合、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) |