字符串匹配问题
来源:互联网 发布:ai软件培训 编辑:程序博客网 时间:2024/05/21 22:58
问题:给定字符串“This is a string”,删除字符串中的“is”。
代码:
- /*return the remainder string*/
- char * matchstr(const char * src,const char *substr)
- {
- const char * p = substr;
- int i = 0;
- int src_len = strlen(src);
- int sub_len = strlen(substr);
- int buf_len = src_len;
- char *tmp_buf = new char[src_len+1];
- char * buf = NULL;
- while(*src!='/0')
- {
- const char * ptmp = strstr(src,p);
- if(ptmp!=NULL){
- while(src<ptmp)//copy strings which is befor ptmp postion into tmp_buf.
- {
- tmp_buf[i]=*src;
- ++i;
- ++src;
- }
- src = src+sub_len;
- }else{//if not match substr in src,then copy all string into tmp_buf
- while(*src!='/0')
- {
- tmp_buf[i]=*src;
- ++i;
- ++src;
- }
- }
- }
- tmp_buf[i]='/0';
- buf_len = strlen(tmp_buf);
- buf = new char[buf_len+1];
- strcpy(buf,tmp_buf);
- delete[] tmp_buf;
- return buf;
- }
- 字符串查找匹配问题
- 字符串匹配问题
- 中文字符串匹配问题
- 字符串匹配问题
- 字符串匹配问题
- 字符串匹配问题
- 字符串匹配问题
- 字符串匹配问题
- js 字符串 匹配问题
- 字符串匹配问题
- 字符串匹配问题
- 字符串匹配问题
- 字符串匹配问题
- 字符串匹配问题
- 字符串匹配问题
- 字符串通配符匹配问题
- 字符串匹配问题
- 1063:字符串匹配问题
- Effective C#之8:Ensure That 0 Is a Valid State for Value Types
- ping命令_详细帮助
- Oracle 10g Automatic Storage Management, Part 1: Overview
- 加入行业网联盟 企业发展提速-访汽车钢铁网CEO刘文利
- MPlayer
- 字符串匹配问题
- 个人网络资源备清单
- 茶叶行业网站的盈利模式探讨
- Oracle的高水位线(High Water Mark)
- OSI各层使用的协议
- 与反射有关的类
- 我们一起来编程!
- Oracle truncate table 与 delete tabel的区别
- 随便写点