Parsing the string and populate the map

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();

    // ...
}

Demo

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top