void Split(const std::string& s,
const std::string& delim,
std::vector<std::string>* ret) {
size_t last = 0;
size_t index = s.find_first_of(delim, last);
while (index != std::string::npos) {
ret->push_back(s.substr(last, index-last));
last = index + 1;
index = s.find_first_of(delim, last);
}
if (index - last > 0) {
ret->push_back(s.substr(last, index - last));
}
}
C++用string类写split方法
最新推荐文章于 2024-07-25 18:17:30 发布