#include <iostream>
#include <string>
#include <regex>
int main()
{
std::string text("bbcaXXXXXY");
// std::regex ex("([abc]{2,4})(.{1})X*.");
std::regex ex("(....)(.)X*.");
std::smatch results;
if( std::regex_match(text, results, ex) )
{
auto index = 0;
for( auto sub : results )
{
if( ++index == 1 ) // whole match
continue;
std::cout << "----" << std::endl;
if( sub.matched )
{
std::cout << sub.str() << std::endl;
}
else
std::cout << "残念" << std::endl;
}
}
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8cmVnZXg+CgppbnQgbWFpbigpCnsKICAgIHN0ZDo6c3RyaW5nIHRleHQoImJiY2FYWFhYWFkiKTsKCi8vCXN0ZDo6cmVnZXggZXgoIihbYWJjXXsyLDR9KSguezF9KVgqLiIpOwoJc3RkOjpyZWdleCBleCgiKC4uLi4pKC4pWCouIik7CgoJc3RkOjpzbWF0Y2ggcmVzdWx0czsKCWlmKCBzdGQ6OnJlZ2V4X21hdGNoKHRleHQsIHJlc3VsdHMsIGV4KSApCgl7CgkJYXV0byBpbmRleCA9IDA7CgkJZm9yKCBhdXRvIHN1YiA6IHJlc3VsdHMgKQoJCXsKCQkJaWYoICsraW5kZXggPT0gMSApIC8vIHdob2xlIG1hdGNoCgkJCQljb250aW51ZTsKCgkJCXN0ZDo6Y291dCA8PCAiLS0tLSIgPDwgc3RkOjplbmRsOwoJCQlpZiggc3ViLm1hdGNoZWQgKQoJCQl7CgkJCQlzdGQ6OmNvdXQgPDwgc3ViLnN0cigpIDw8IHN0ZDo6ZW5kbDsKCQkJfQoJCQllbHNlCgkJCQlzdGQ6OmNvdXQgPDwgIuaui+W/tSIgPDwgc3RkOjplbmRsOwoJCX0KCX0KfQo=