Skip to content

Instantly share code, notes, and snippets.

@skhaz
Created June 12, 2011 23:46
Show Gist options
  • Save skhaz/1022136 to your computer and use it in GitHub Desktop.
Save skhaz/1022136 to your computer and use it in GitHub Desktop.
std::map<std::string, std::string> result;
std::string str("foo=bar&color=red&zoom=22.5&alpha=3,4,2,1222.8");
sregex pair = ( (s1= +_w) >> "=" >> (s2= +(set[alnum | '_' | '.' | ',']) ))
[ ref(result)[s1] = s2];
sregex rx = pair >> *('&' >> *(pair));
if(regex_match(str, rx)) {
std::map<std::string, std::string>::const_iterator it;
for (it = result.begin(); it != result.end(); ++it) {
std::cout << "key '" << it->first << "' value '" << it->second << "'" << std::endl;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment