#include <string>
#include <iostream>
#include <regex>
using namespace std;
int main( ) {
std:: regex r( "ab(c)" ) ;
std:: string s = "abcdefabcghiabc" ;
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 ' ;
std:: cout << " Capture: " << m[ 1 ] .str ( ) << " at Position " << m.position ( 1 ) << '\n ' ;
}
return 0 ;
}
I2luY2x1ZGUgPHN0cmluZz4KI2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8cmVnZXg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbWFpbigpIHsKCXN0ZDo6cmVnZXggcigiYWIoYykiKTsKCXN0ZDo6c3RyaW5nIHMgPSAiYWJjZGVmYWJjZ2hpYWJjIjsKCWZvcihzdGQ6OnNyZWdleF9pdGVyYXRvciBpID0gc3RkOjpzcmVnZXhfaXRlcmF0b3Iocy5iZWdpbigpLCBzLmVuZCgpLCByKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpICE9IHN0ZDo6c3JlZ2V4X2l0ZXJhdG9yKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKytpKQogICAgewogICAgICAgIHN0ZDo6c21hdGNoIG0gPSAqaTsKICAgICAgICBzdGQ6OmNvdXQgPDwgIk1hdGNoIHZhbHVlOiAiIDw8IG0uc3RyKCkgPDwgIiBhdCBQb3NpdGlvbiAiIDw8IG0ucG9zaXRpb24oKSA8PCAnXG4nOwogICAgICAgIHN0ZDo6Y291dCA8PCAiICAgIENhcHR1cmU6ICIgPDwgbVsxXS5zdHIoKSA8PCAiIGF0IFBvc2l0aW9uICIgPDwgbS5wb3NpdGlvbigxKSA8PCAnXG4nOwogICAgfQoJcmV0dXJuIDA7Cn0K