With regex, you might do:
std::string s1 = "command1 -keep -path { {path1} } { {./input.doc} }";
std::regex pattern{R"((.*)-path \{ \{([^}]*)\} \}(.*))"};
std::smatch obj;
if (std::regex_match(s1, obj, pattern))
{
std::string key = obj[1].str() + obj[3].str();
std::string value = obj[2].str();
// ...
}
CLICK HERE to find out more related problems solutions.