正则表达式匹配
2016-04-29 11:14
302 查看
class Solution { public: bool matchTrue(char* str, char* pattern) { if(*str=='\0'&&*pattern=='\0') return true; else if(*str!='\0'&&*pattern=='\0') return false; if(*(pattern+1)=='*') { if(*str==*pattern||(*pattern=='.'&&*str!='\0')) return matchTrue(str,pattern+2)||matchTrue(str+1,pattern+2)||matchTrue(str+1,pattern); else return matchTrue(str,pattern+2); } else { if(*str==*pattern||(*pattern=='.'&&*str!='\0')) return matchTrue(str+1,pattern+1); else return false; } return false; } bool match(char* str, char* pattern) { if(str==NULL||pattern==NULL) return false; return matchTrue(str,pattern); } };
相关文章推荐
- 软考信息系统监理师:2016年4月22日作业
- C# 自定义Json解析工具
- CSS 属性选择器
- Android适配不同屏幕
- MVVM模式下如何使用ReactiveCocoa响应链式编程<二>
- ld: library not found for -lAFNetworking
- nyoj_39 水仙花数
- 基本光照与阴影(一)
- 资料文档
- common-codec加解密base64
- 如何描述PCIe SSD性能的稳定性?
- CSS 类选择器
- C++中的inline关键字
- SVN使用教程总结
- 检测wifi是否需要portal验证 公共场所wifi验证
- 无限极分类查找子孙树
- HDFS存储容量扩充
- [source Tree] rebase crrent changes onto [分支名]
- ArcGIS教程:报表快速浏览
- 如何让自己的网站获得过万流量