cocos2d-x 对传入的字符串进行解析分割 解析
2013-11-27 13:35
344 查看
//对传入的字符串进行解析分割
vector<std::string> schoolBusLayer::httpGetDateSplit(std::string str,std::string separator )
{
vector<string> result;
string::size_type cutAt =0;
int times = 1;
int lastAt = 0;
while( (cutAt = str.find_first_of(separator,times))!=str.npos )
{
if(cutAt > 0)
{
result.push_back(str.substr(0, cutAt));
}
str = str.substr(cutAt + 3);
}
if(str.length() > 0)
{
result.push_back(str);
}
return result;
}
用法:std::vector<string> vec_str_num; vec_str_num= httpGetDateSplit(bufferSchool,"101");
vector<std::string> schoolBusLayer::httpGetDateSplit(std::string str,std::string separator )
{
vector<string> result;
string::size_type cutAt =0;
int times = 1;
int lastAt = 0;
while( (cutAt = str.find_first_of(separator,times))!=str.npos )
{
if(cutAt > 0)
{
result.push_back(str.substr(0, cutAt));
}
str = str.substr(cutAt + 3);
}
if(str.length() > 0)
{
result.push_back(str);
}
return result;
}
用法:std::vector<string> vec_str_num; vec_str_num= httpGetDateSplit(bufferSchool,"101");
相关文章推荐
- 306. Additive Number 给定字符串分割进行类似斐波那契数列
- C# 对字符串进行分离 split 字符串分割 "aaaa---bbbb---ccc"方法
- cocos2d-x 分割字符串
- GetCommandLine 获取当前进程的命令行字符串 对字符串进行分割
- 调用webservice,解析返回数据为xml格式的字符串,进行数据绑定
- 对一个字符串实现反转,如果存在分号或者逗号等,则按照符号分割分别进行反转
- javascritp 传入对象或数组生成json字符串 解析json字符串
- 简述c#中对字符串进行分割的几种方法
- maven项目对json字符串进行解析
- SQL字符串分割解析
- 将字符串按长度进行倒序排序——传入Collections.reverseOrder一个已有比较器
- 调用webservice,解析返回数据为xml格式的字符串,进行数据绑定
- Java中用split函数进行分割字符串。
- [寒江孤叶丶的Cocos2d-x之旅_20]Lua字符串分割函数分享,Lua StringSplit
- mysql如何进行以,分割的字符串的拆分
- c++ 字符串分割一、用strtok函数进行字符串分割 原型: char *strtok(char *str, const char *delim); 功能:分解字符串为一组字符串。 参数说明:
- c#字符串以特定字符串进行分割
- java 发送http请求 返回字符串 再进行解析(略)
- 从txt文件读取内容并进行字符串分割
- 传入字符串,解析后分别操作