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