#include <iostream>
#include <regex>
#include <string>
using namespace std;
int main() {
std::regex r("^\\d+$");
std::string s = "1\n2\n3";
for(std::sregex_iterator i = std::sregex_iterator(s.begin(), s.end(), r);
i != std::sregex_iterator();
++i)
{
std::smatch m = *i;
std::cout << "Match value: " << m.str() << " at Position " << m.position() << '\n';
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8cmVnZXg+CiNpbmNsdWRlIDxzdHJpbmc+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbWFpbigpIHsKCXN0ZDo6cmVnZXggcigiXlxcZCskIik7CiAgICBzdGQ6OnN0cmluZyBzID0gIjFcbjJcbjMiOwogICAgZm9yKHN0ZDo6c3JlZ2V4X2l0ZXJhdG9yIGkgPSBzdGQ6OnNyZWdleF9pdGVyYXRvcihzLmJlZ2luKCksIHMuZW5kKCksIHIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgIGkgIT0gc3RkOjpzcmVnZXhfaXRlcmF0b3IoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICArK2kpCiAgICB7CiAgICAgICAgc3RkOjpzbWF0Y2ggbSA9ICppOwogICAgICAgIHN0ZDo6Y291dCA8PCAiTWF0Y2ggdmFsdWU6ICIgPDwgbS5zdHIoKSA8PCAiIGF0IFBvc2l0aW9uICIgPDwgbS5wb3NpdGlvbigpIDw8ICdcbic7CiAgICB9CglyZXR1cm4gMDsKfQ==