C++字符串分割
2014-10-08 20:46
253 查看
//字符串分割函数 std::vector<std::string> split(std::string str,std::string pattern) { std::string::size_type pos; std::vector<std::string> result; str+=pattern;//扩展字符串以方便操作 int size=str.size(); for(int i=0; i<size; i++) { pos=str.find(pattern,i); if(pos<size) { std::string s=str.substr(i,pos-i); result.push_back(s); i=pos+pattern.size()-1; } } return result; }
相关文章推荐
- C++中使用指定字符分割字符串
- C++分割字符串的类
- 【转】C/C++中的Split函数(字符串自动分割)
- c++中怎么分割字符串之strtok 函数
- 分割字符串 c++
- 标准C++ 与MFC 6.0 中字符串的分割
- C/C++中的输出字符串分割和对齐
- C++字符串分割
- c/c++ 字符串分割 (strtok)
- C/C++_字符串分割strtok函数
- C/C++分割字符串:strtok函数
- C++MFC分割字符串
- C++ 分割字符串
- c++字符串分割(转)
- C/C++中的字符串分割
- C++中利用STD库函数分割字符串
- c++编写字符串分割函数
- c++ 字符串分割
- C++ 使用正则表达式分割字符串
- [C++]逐行读取文件与分割字符串方法