#include <iostream>
#include <vector>
#include <regex>
int main() {
const std::regex reg("\\{(.*?)\\}(?![^;])");
std::smatch match;
std::string s = "Username={My_{}user};Password={my_pswd}}123}}}kk};Password={my_pswd}}123}";
std::vector<std::string> results(
std::sregex_token_iterator(s.begin(), s.end(), reg, 1),
std::sregex_token_iterator());
for (auto result : results)
{
std::cout << result << std::endl;
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8cmVnZXg+CiAKaW50IG1haW4oKSB7CiAgIGNvbnN0IHN0ZDo6cmVnZXggcmVnKCJcXHsoLio/KVxcfSg/IVteO10pIik7CiAgIHN0ZDo6c21hdGNoIG1hdGNoOwogICBzdGQ6OnN0cmluZyBzID0gIlVzZXJuYW1lPXtNeV97fXVzZXJ9O1Bhc3N3b3JkPXtteV9wc3dkfX0xMjN9fX1ra307UGFzc3dvcmQ9e215X3Bzd2R9fTEyM30iOwogICBzdGQ6OnZlY3RvcjxzdGQ6OnN0cmluZz4gcmVzdWx0cygKICAgCQlzdGQ6OnNyZWdleF90b2tlbl9pdGVyYXRvcihzLmJlZ2luKCksIHMuZW5kKCksIHJlZywgMSksCgkJc3RkOjpzcmVnZXhfdG9rZW5faXRlcmF0b3IoKSk7CiAgIGZvciAoYXV0byByZXN1bHQgOiByZXN1bHRzKQogICB7CiAgICAgIHN0ZDo6Y291dCA8PCByZXN1bHQgPDwgc3RkOjplbmRsOwogICB9CiAKICAgcmV0dXJuIDA7Cn0=