字符串分割使用方法
来源:互联网 发布:淘宝客程序2.0 编辑:程序博客网 时间:2024/05/17 03:25
// splitstring.cpp : Defines the entry point for the console application.//#include "stdafx.h"#pragma warning(disable : 4786)#include <vector>#include <string>//字符串分割函数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;}int main(int argc, char* argv[]){std::vector<std::string> szArry;szArry = split("good,asdf,asdf,as,dfas,df,asdf,as,dfas",",");std::vector<std::string>::iterator index;for (index = szArry.begin(); index != szArry.end(); index++){printf("%s\n",(*index).c_str() );}return 0;}
分割函数,是某个大侠写的,这里借用了一下!
vector<CString> split(CString str,CString pattern) { int pos; vector<CString> result; str+=pattern;//扩展字符串以方便操作 int size=str.GetLength(); for(int i=0; i<size; i++) { pos = str.Find(pattern,i);if(pos<size) { CString s=str.Mid(i,pos-i); result.push_back(s); i = pos + pattern.GetLength() - 1;} } return result; }
0 0
- 字符串分割使用方法
- Split分割字符串使用方法 例子 部分正则表达式
- 分割字符串
- 分割字符串
- 分割字符串
- 分割字符串
- 分割字符串
- 字符串分割
- 字符串分割
- 分割字符串
- 字符串分割
- 字符串分割
- 分割字符串
- 分割字符串
- 分割字符串
- 字符串分割
- 分割字符串
- 字符串分割
- hadoop之"hello world"--wordCount
- tcpdump抓包
- [Grails]使用Grails的Console执行简单的CRUD操作
- POJ 2455 二分最大流。
- SRM 605 D1 L2:AlienAndSetDiv1,DP,bitmask
- 字符串分割使用方法
- broken necklace
- linux的fnctl设置FD_CLOEXEC
- hdu Safecracker(回溯)
- java String 缓存池问题
- POJ 2455 二分+网络流
- java 字节流与字符流的区别
- oracle 数据库单子段多条记录合并一条记录函数
- tcpdump的使用