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