#include <iostream>
#include <string>
#include <regex>
using namespace std;
int main() {
string str("abcdefabcghiabc");
int i = 0;
regex rgx1("abc");
smatch smtch;
while (regex_search(str, smtch, rgx1)) {
std::cout << i << ": " << smtch[0] << std::endl;
i += 1;
str = smtch.suffix().str();
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8cmVnZXg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbWFpbigpIHsKCXN0cmluZyBzdHIoImFiY2RlZmFiY2doaWFiYyIpOwoJaW50IGkgPSAwOwoJcmVnZXggcmd4MSgiYWJjIik7CglzbWF0Y2ggc210Y2g7Cgl3aGlsZSAocmVnZXhfc2VhcmNoKHN0ciwgc210Y2gsIHJneDEpKSB7CgkJCXN0ZDo6Y291dCA8PCBpIDw8ICI6ICIgPDwgc210Y2hbMF0gPDwgc3RkOjplbmRsOwoJCQlpICs9IDE7CgkJCXN0ciA9IHNtdGNoLnN1ZmZpeCgpLnN0cigpOwoJCX0KCglyZXR1cm4gMDsKfQoKCg==