#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;
		}
	}
}
