1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
// match_results::position
// * using smatch, a standard alias of match_results<string::iterator>
#include <iostream>
#include <string>
#include <regex>
int main ()
{
std::string s ("test subject");
std::smatch m;
std::regex e ("(sub)(.*)");
std::regex_search ( s, m, e );
for (unsigned i=0; i<m.size(); ++i) {
std::cout << "match " << i << " (" << m[i] << ") ";
std::cout << "at position " << m.position(i) << std::endl;
}
return 0;
}
|