std::match_results<BidirIt,Alloc>::position
提供: cppreference.com
<tbody>
</tbody>
difference_type position( size_type n = 0 ) const; |
(C++11以上) | |
指定された部分マッチの最初の文字の位置を返します。
n == 0 であれば、マッチした表現全体の最初の文字の位置を返します。
n > 0 && n < size() であれば、 n 番目の部分マッチの最初の文字の位置が返されます。
n >= size() であれば、マッチしなかったマッチの最初の文字の位置が返されます。
引数
| n | - | 調べるマッチを指定する整数 |
戻り値
指定されたマッチまたは部分マッチの最初の文字の位置。
例
Run this code
#include <iostream>
#include <regex>
#include <string>
int main()
{
std::regex re("a(a)*b");
std::string target("aaab");
std::smatch sm;
std::regex_match(target, sm, re);
std::cout << sm.position(1) << '\n';
}
出力:
1
関連項目
| 指定された部分マッチを返します (パブリックメンバ関数) |