@xiaohui7

Thanks for your genius idea and someone's blog from csdn(link:http://blog.csdn.net/hk2291976/article/details/51165010).

I try the recursive code with python3.

class Solution:

def isMatch(self, s, p): return self.match(s, len(s) - 1, p, len(p) - 1) def match(self, s, i, p, j): if j == -1: if i == -1: return True else: return False if p[j] == '*': if i > -1 and (p[j-1] == '.' or p[j-1] == s[i]): if self.match(s, i-1, p, j): return True return self.match(s, i, p, j-2) if i >=0 and j>=0: if (p[j] == '.' or p[j] == s[i]): return self.match(s, i-1, p, j-1) return False