C++字符串切分: split实现
2013-10-06 18:00
309 查看
std::vector<std::string> split(const std::string& s, const std::string& delim) { std::vector<std::string> elems; size_t pos = 0; size_t len = s.length(); size_t delim_len = delim.length(); if (delim_len == 0) return elems; while (pos < len) { int find_pos = s.find(delim, pos); if (find_pos < 0) { elems.push_back(s.substr(pos, len - pos)); break; } elems.push_back(s.substr(pos, find_pos - pos)); pos = find_pos + delim_len; } return elems; }
相关文章推荐
- c/c++实现字符串分隔split
- C++:实现split分割字符串
- C/C++实现split分割字符串
- C++:实现split分割字符串
- C++拆分字符串代码(实现split)
- C/C++实现split分割字符串
- c++实现split()字符串切片
- C++ 字符串分割方法 实现split
- C++字符串分割函数split实现
- 在C++中实现字符串分割--split
- JAVA利用split实现切分字符串
- .NET中字符串split的C++实现
- C++:实现split分割字符串 - 改进
- C++:实现split分割字符串
- C++:实现split分割字符串
- C++ split 字符串分割实现
- C++:实现split分割字符串
- C++:实现split分割字符串
- How to split string in C++(分割字符串)
- c++实现aes加密算法,对字符串进行加密