MFC实现python中的split功能
2011-05-29 21:08
591 查看
新博客地址:http://gorthon.sinaapp.com/
用法:
CString src = "!!。@你好@abc@你好的很@生日快乐@和@谐";
CString sep = "@";
vector<CString> dest;
split(src, dest, sep);
结果如下图(dest数组中显示的时候每个元素后面添加了"/r/n"):
CString src = "!!。@你好@abc@你好的很@生日快乐@和@谐";
CString sep = "你好";
vector<CString> dest;
split(src, dest, sep);
结果如下图(dest数组中显示的时候每个元素后面添加了"/r/n"):
CString src = "大家@@你好@abc@你好的很@生日快乐@和@谐";
CString sep = "@";
vector<CString> dest;
split(src, dest, sep);
结果如下图(dest数组中显示的时候每个元素后面添加了"/r/n"):
下面是python的:
void FunctionPy::split(const CString src, vector<CString> &dest, const CString division) { CString src_copy(src); int sep_length = division.GetLength(); for (int i=0; i<src_copy.GetLength(); i++) { if (src_copy.Mid(i, sep_length) == division) { dest.push_back(src_copy.Left(i)); // push左边i个 src_copy = src_copy.Right(src_copy.GetLength() - i - sep_length); // 去掉左边i个及division本身 i = -1; // 回到for循环后i++使得i = 0,重复…… } } dest.push_back(src_copy); }
用法:
CString src = "!!。@你好@abc@你好的很@生日快乐@和@谐";
CString sep = "@";
vector<CString> dest;
split(src, dest, sep);
结果如下图(dest数组中显示的时候每个元素后面添加了"/r/n"):
CString src = "!!。@你好@abc@你好的很@生日快乐@和@谐";
CString sep = "你好";
vector<CString> dest;
split(src, dest, sep);
结果如下图(dest数组中显示的时候每个元素后面添加了"/r/n"):
CString src = "大家@@你好@abc@你好的很@生日快乐@和@谐";
CString sep = "@";
vector<CString> dest;
split(src, dest, sep);
结果如下图(dest数组中显示的时候每个元素后面添加了"/r/n"):
下面是python的:
相关文章推荐
- 实现Python str.split功能的小函数
- 兄弟连学Python(14)-----实现split的功能
- 【Python】实现字符串分割功能 类似于str.split()
- Python paramiko 实现堡垒机功能
- D-Bus入门(四)——QTDBUS代码,实现ofono代码下的python测试文件activite-context的功能
- python实现简单爬虫功能
- 托盘功能的实现(MFC)
- Python网络编程使用select实现socket全双工异步通信功能示例
- 装饰器实现Python web框架路由功能
- Python实现计算器功能
- Python:通过摄像头实现的监控功能
- python使用paramiko模块实现ssh远程命令执行,与sftp文件下载功能
- 听歌识曲--用python实现一个音乐检索器的功能
- python实现上传下载文件功能
- python---名片管理(并对名片进行增、删、改、查、功能的实现)
- Python网络编程:E-mail服务(八) 实现抄送和密送功能
- Python实现的单向循环链表功能示例
- 《MFC实现文件打开和保存功能实现》
- python_使用sched实现定时功能
- Python3.x实现网页登录表单提交功能