1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
// sub_match::length
#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[i].length() << std::endl;
}
return 0;
}
|