leetcode Regular Expression Matching

class Solution {
public:
    bool isMatch(const char *s, const char *p) 
    {
       assert(s && p);
       if(*p=='\0')
       return *s == '\0';
       if (*(p+1)!='*') 
       {
          assert(*p != '*');
          return ((*p == *s) || (*p == '.' && *s != '\0')) && isMatch(s+1, p+1);
       }
    // next char is '*'
       while ((*p == *s) || (*p == '.' && *s != '\0')) 
       {
         if (isMatch(s, p+2)) return true;
         s++;
       }
       return isMatch(s, p+2);
   }
};
原文地址:https://www.cnblogs.com/tgkx1054/p/3134516.html