regular expression matching

🏠
 1 class Solution(object):
 2     def isMatch(self, s, p):
 3         def m(s, p):
 4             if not p:
 5                 return not s
 6 
 7             fm = s and p[0] in {s[0], "."}
 8             star_match = len(p) >= 2 and p[1] == "*"
 9 
10             if star_match:
11                 return fm and m(s[1:], p) or m(s, p[2:])
12             else:
13                 return fm and m(s[1:], p[1:])
14         return m(s, p)
15 
16 print(Solution().isMatch("miss", "mis*"))