1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
// match_results::ready
// - using smatch, a standard alias of match_results<string::iterator>
#include <iostream>
#include <string>
#include <regex>
int main ()
{
std::string mystring ("subject");
std::smatch mymatch;
std::regex myregex ("sub.*");
std::cout << std::boolalpha;
std::cout << "mymatch.ready() is " << mymatch.ready() << std::endl;
std::regex_match ( mystring, mymatch, myregex );
std::cout << "attempting match..." << std::endl;
std::cout << "mymatch.ready() is " << mymatch.ready() << std::endl;
if (mymatch.ready()) std::cout << "matched: " << mymatch[0] << std::endl;
return 0;
}
|