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::empty
// - using smatch, a standard alias of match_results<string::iterator>
#include <iostream>
#include <string>
#include <regex>
int main ()
{
using namespace std::regex_constants;
std::string s ("Subject");
std::regex e1 ("sub.*");
std::regex e2 ("sub.*", ECMAScript | icase);
std::smatch m1,m2;
std::regex_match ( s, m1, e1 );
std::regex_match ( s, m2, e2 );
std::cout << "e1 " << ( m1.empty() ? "did not match" : "matched" ) << std::endl;
std::cout << "e2 " << ( m2.empty() ? "did not match" : "matched" ) << std::endl;
return 0;
}
|