C++/代码

class Solution {
public:
    bool match(char* str, char* pattern) {
        if (*str == '\0' && *pattern == '\0') return true;
        if (*(pattern+1) != '*') 
            if (*str == *pattern || (*pattern == '.' && *str != '\0')) return match(str + 1,pattern + 1); //情况1或者情况2
            else return false; //str不为结束符则继续,判定pattern+1是不是*
        else {
            if (*str == *pattern || (*pattern == '.' && *str != '\0')) return  match(str,pattern + 2) || match(str + 1,pattern);
            else return match(str,pattern + 2);
        }
    }
};