正则表达式匹配
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); } };