1 static void SplitString(const string& data, const string& delim, 2 std::vector<string>* result) { 3 std::string::size_type pos; 4 const int size = data.size(); 5 6 for(int index = 0; index < size; ++index) { 7 pos = data.find(delim, index); 8 if (std::string::npos != pos && 9 pos < size) { 10 result->emplace_back(data.substr(idx, pos - index)); 11 index = pos + delim.size()-1; 12 } else { // 最后一个element 13 result->emplace_back(data.substr(index)); 14 } 15 }19 }
标签:index,string,delim,pos,c++,拆分,字符串,data,size From: https://www.cnblogs.com/guoliushui/p/17293921.html