分解字符串
来源:互联网 发布:腿长 知乎 编辑:程序博客网 时间:2024/05/16 19:47
#include <string>
#include <iostream>
#include <vector>
using namespace std;
int main()
{
string test = "a@a;a@a;bb@c;cc@cd";
string toaddress="cdd@dccd";
vector<string> strvec;
string strtemp;
string::size_type pos1, pos2;
pos2 = test.find(';');
pos1 = 0;
while (string::npos != pos2)
{
strvec.push_back(test.substr(pos1, pos2 - pos1));
pos1 = pos2 + 1;
pos2 = test.find(';', pos1);
}
strvec.push_back(test.substr(pos1));
vector<string>::iterator iter1 = strvec.begin(), iter2 = strvec.end();
while (iter1 != iter2)
{
if((*iter1).length())
{
std::string::size_type poss((*iter1).find("@"));
if(poss != std::string::npos) { //found the server beginning
if(++poss < (*iter1).length())
cout<<(*iter1).substr(poss, (*iter1).length()- poss)<<endl;
}
}
++iter1;
}
return 0;
}
- 分解字符串
- 字符串分解
- 分解字符串
- 分解字符串
- 分解字符串
- 分解字符串
- 分解字符串
- 分解字符串
- 分解字符串
- 分解字符串
- 分解字符串
- 分解字符串方法
- 字符串分解(strtok)
- 字符串分解和连接
- 字符串分解和连接
- 字符串分解之StroK
- JS分解字符串split
- delphi 字符串函数分解
- 移植uCOS ii到ARM920T
- c# 启动单个程序
- ruby关于检查IP地址正则的例子
- JAVA与C#比较
- linux下挂载windows虚拟目录
- 分解字符串
- 使用 gperf 实现高效的 C/C++ 命令行处理
- 开发必备软件
- linux 查看文件夹大小
- JSP与ASP.NET简单之比较!
- 理解产品经理
- C#中如何调用DOS命令
- JS中包含其它JS文件
- MTK之GPRS相关文档