std::vector<std::string> split(std::string s, std::string delimiter)
{
std::vector<std::string> tokens;
size_t pos = 0;
std::string token;
while ((pos = s.find(delimiter)) != std::string::npos) {
token = s.substr(0, pos);
tokens.push_back(token);
s.erase(0, pos + delimiter.length());
}
if(int(s.length()) > 0)
{
tokens.push_back(s);
}
return tokens;
}
其他参考:
https://zhuanlan.zhihu.com/p/56163976
How to split a string in C++:
https://www.fluentcpp.com/2017/04/21/how-to-split-a-string-in-c/