#include <iostream>
#include <regex>
#include <string>
using namespace std;
int main() {
string foo("lorem ipsum");
match_results<string::reverse_iterator> sm;
if(regex_match(foo.rbegin(), foo.rend(), sm, regex("(\\w+)\\s+(\\w+)"))){
cout << sm[1] << ' ' << sm[2] << endl;
}else{
cout << "bad\n";
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8cmVnZXg+CiNpbmNsdWRlIDxzdHJpbmc+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbWFpbigpIHsKCXN0cmluZyBmb28oImxvcmVtIGlwc3VtIik7CgltYXRjaF9yZXN1bHRzPHN0cmluZzo6cmV2ZXJzZV9pdGVyYXRvcj4gc207CgkKCWlmKHJlZ2V4X21hdGNoKGZvby5yYmVnaW4oKSwgZm9vLnJlbmQoKSwgc20sIHJlZ2V4KCIoXFx3KylcXHMrKFxcdyspIikpKXsKCQljb3V0IDw8IHNtWzFdIDw8ICcgJyA8PCBzbVsyXSA8PCBlbmRsOwoJfWVsc2V7CgkJY291dCA8PCAiYmFkXG4iOwoJfQoJCglyZXR1cm4gMDsKfQ==