#include <iostream>
#include <regex>
using namespace std;
int main() {
std::vector<std::string> strings;
strings.push_back("T441_S45/1");
strings.push_back("007_S4");
strings.push_back("41_445T02_74");
std::regex reg(R"(^\D*(\d+)(?:\D+(\d+))?(?:\D+(\d+))?[\s\S]*)");
for (size_t k = 0; k < strings.size(); k++)
{
std::cout << "Input string: " << strings[k] << std::endl;
std::cout << "Replace result: "
<< std::regex_replace(strings[k], reg, "$1 $2 $3") << std::endl;
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8cmVnZXg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbWFpbigpIHsKCXN0ZDo6dmVjdG9yPHN0ZDo6c3RyaW5nPiBzdHJpbmdzOwoJc3RyaW5ncy5wdXNoX2JhY2soIlQ0NDFfUzQ1LzEiKTsKCXN0cmluZ3MucHVzaF9iYWNrKCIwMDdfUzQiKTsKCXN0cmluZ3MucHVzaF9iYWNrKCI0MV80NDVUMDJfNzQiKTsKCglzdGQ6OnJlZ2V4IHJlZyhSIiheXEQqKFxkKykoPzpcRCsoXGQrKSk/KD86XEQrKFxkKykpP1tcc1xTXSopIik7Cglmb3IgKHNpemVfdCBrID0gMDsgayA8IHN0cmluZ3Muc2l6ZSgpOyBrKyspCgl7CgkJc3RkOjpjb3V0IDw8ICJJbnB1dCBzdHJpbmc6ICIgPDwgc3RyaW5nc1trXSA8PCBzdGQ6OmVuZGw7CgkJc3RkOjpjb3V0IDw8ICJSZXBsYWNlIHJlc3VsdDogIiAKCQkgICAgICAgICAgICAgPDwgc3RkOjpyZWdleF9yZXBsYWNlKHN0cmluZ3Nba10sIHJlZywgIiQxICQyICQzIikgPDwgc3RkOjplbmRsOwoJfQoJcmV0dXJuIDA7Cn0=