#include <iostream>
#include <regex>
#include <string>
using namespace std;

int main() {
	regex rx(R"((\w+) ([[:digit:]]+), ([[:digit:]]+)(\([[:digit:]]+\)))");
	string s("Text lw 2, 3(9) here");
	smatch m;
	if (regex_search(s, m, rx)) {
		std::cout << m.str() << std::endl;
		std::cout << m.str(1) << std::endl;
		std::cout << m.str(2) << std::endl;
		std::cout << m.str(3) << std::endl;
		std::cout << m.str(4) << std::endl;
	}
	return 0;
}