(转帖)C++中自己实现的split函数
由于太久远了,已经忘记作者是谁了,如果看到了,真的对不起,希望能给我留个言(我的QQ:543451622)
void split(const string& src, const string& separator, vector<string>& dest)
{
string str = src;
string substring;
string::size_type start = , index; do
{
index = str.find_first_of(separator,start);
if (index != string::npos)
{
substring = str.substr(start,index-start);
dest.push_back(substring);
start = str.find_first_not_of(separator,index);
if (start == string::npos) return;
}
}while(index != string::npos); //the last token
substring = str.substr(start);
dest.push_back(substring);
}
(转帖)C++中自己实现的split函数的更多相关文章
- python 中的os.path.split()函数用法
基本概念 os.path.split()通过一对链表的头和尾来划分路径名.链表的tail是是最后的路径名元素.head则是它前面的元素. 举个例子: path name = '/home/User ...
- java中split函数参数特殊字符的处理(转义),如:"." 、"\"、"|"
内容介绍 本文主要介绍java中特殊字符做为split函数的参数,如:"." ."\"."|",双引号等,不能正确分隔源字符串的处理方法. ...
- perl:split函数用法
本文和大家重点讨论一下Perl split函数的用法,Perl中的一个非常有用的函数是Perl split函数-把字符串进行分割并把分割后的结果放入数组中.这个Perl split函数使用规则表达式( ...
- 在C++中实现字符串分割--split
字符串分割 在一些比较流行的语言中,字符串分割是一个比较重要的方法,不论是在python,java这样的系统级语言还是js这样的前端脚本都会在用到字符串的分割,然而在c++中却没有这样的方法用来调用. ...
- Python中的join()函数split()函数
函数:string.join() Python中有join()和os.path.join()两个函数,具体作用如下: join(): 连接字符串数组.将字符串.元组.列表中的元素以指定的 ...
- Python中split()函数的用法及实际使用示例
Python中split()函数,通常用于将字符串切片并转换为列表. 一.函数说明: split():语法:str.split(str="",num=string.count(st ...
- Java中Split函数的用法技巧
在java.lang包中也有String.split()方法,与.net的类似,都是返回是一个字符型数组,但使用过程中还有一些小技巧.如执行:"2|33|4".split(&quo ...
- c#中Split函数的使用介绍
平时经常用到split,在这里做一个系统的总结. Split函数 作用 返回一个下标从零开始的一维数组,它包含指定数目的子字符串. 语法 Split(expression[, ...
- C#中Split函数的使用
Split函数 描述 :返回一个下标从零开始的一维数组,它包含指定数目的子字符串. 语法 :Split(expression[, delimiter[, count[, compare]] ...
随机推荐
- BZOJ2459 : [BeiJing2011]神秘好人
线段树每个节点维护d[4][4]表示四个顶点之间的最短路,合并时用Floyed合并,查询时分三段然后合并. #include<cstdio> #define N 100010 struct ...
- BZOJ 1067 & Interval_Tree
1067: [SCOI2007]降雨量 Time Limit: 1 Sec Memory Limit: 162 MB Submit: 3099 Solved: 800 Description 我们常常 ...
- 【BZOJ】1014: [JSOI2008]火星人prefix(splay+hash+二分+lcp)
http://www.lydsy.com/JudgeOnline/problem.php?id=1014 题意:支持插入一个字符.修改一个字符,查询lcp.(总长度<=100000, 操作< ...
- 【BZOJ】1878: [SDOI2009]HH的项链(树状数组)
http://www.lydsy.com/JudgeOnline/problem.php?id=1878 我太弱了,看题解才过的. 一开始看到此题,我想了想在线做法,但之后觉得这个想法可能是错的:维护 ...
- Strong TLS configuration on servers
- Use certificates with at least sha-256 hash algorithms (including intermediate certificates).- Use ...
- Java正则表达式教程
地址:http://www.java3z.com/cwbwebhome/article/article8/Regex/Java.Regex.Tutorial.html#reg0_1
- mysql中datetime比较大小问题 (转的)
方法一: 你也可以:select * from t1 where unix_timestamp(time1) > unix_timestamp('2011-03-03 17:39:05') an ...
- C#中将ListView中数据导出到Excel
首先 你需要添加引用Microsoft Excel 11.0 Object Library 添加方法:选择项目->引用->右击“添加引用”->选择COM 找到上面组件—>点击“ ...
- CentOS源列表
vi /etc/yum.repos.d/CentOS-Base.repo CentOS 5: # CentOS-Base.repo # # The mirror system uses the con ...
- [IT新应用]存储入门-文件级存储及块级别存储的选择
http://www.techrepublic.com/blog/the-enterprise-cloud/block-level-storage-vs-file-level-storage-a-co ...