标签:
1. 字符串分割
vector<string> split(const string& str, string cutStr) {
vector<string> res;
size_t start = 0;
size_t stop;
while ((stop = str.find(cutStr, start)) != string::npos) {
if (stop > start) {
res.push_back(str.substr(start, stop-start));
}else {
res.push_back("");
}
start = stop + cutStr.length();
}
if(start < str.length()) {
res.push_back(str.substr(start));
}else {
res.push_back("");
}
return res;
}
标签:
原文地址:http://www.cnblogs.com/liyangguang1988/p/5415433.html