std::match_results::position
From Cppreference
< cpp | regex | match results
difference_type position( size_type sub = 0 ) const;
|
(C++11 feature) | |
[edit] Parameters
sub | - | Indicates the sub_match. |
[edit] Return value
Returns the distance from the start of the target sequence to the start of the match.
[edit] Example
#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'; }
Output:
1