对HTTP请求的参数列表进行切割

#include <regex>
int  SpliteQueryString() 
{
	std::string str = "cameraName=xxxx&user=xx&videotype=1";
	std::regex re("([^&=]+)=([^&]*)");
	std::smatch match;

	std::map<std::string, std::string> params;

	std::sregex_iterator end;
	for (std::sregex_iterator i(str.begin(), str.end(), re); i != end; ++i) {
		std::smatch match = *i;
		std::string key = match[1].str();
		std::string value = match[2].str();

		// 去除value中可能存在的'&'字符(如果有的话)  
		size_t pos = value.find('&');
		if (pos != std::string::npos) {
			value.erase(pos);
		}

		params[key] = value;
	}

	// 打印结果  
	for (const auto& pair : params) {
		std::cout << pair.first << ": " << pair.second << std::endl;
	}

	return 0;
}