1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
// match_results::str
// - using cmatch, a standard alias of match_results<const char*>
#include <iostream>
#include <string>
#include <regex>
int main ()
{
using namespace std::regex_constants;
std::cmatch m;
std::regex_match ( "subject", m, std::regex("(sub)(.*)") );
std::string output = "matches:\n";
for (unsigned i=0; i<m.size(); ++i) {
output+= m.str(i) + "\n";
}
std::cout << output << std::endl;
return 0;
}
| |