class Solution:
"""
@param s: A string
@param p: A string includes "?" and "*"
@return: is Match?
"""
def isMatch(self, s, p):
# write your code here
# 这个跟之前那个正则表达式很像,从前往后逐个比对
k = 0
if len(s) == 0 and len(p) == 0:
return True
elif len(s) == 0 or len(p) == 0:
if len(s) == 0 and len(p) == 1 and p[0] == '*':
return True
return False
else:
if s[0] == p[0] or p[0] == '?':
return self.isMatch(s[1:],p[1:])
elif p[0] == '*':
return self.isMatch(s[1:],p[1:]) or self.isMatch(s[1:],p) or self.isMatch(s,p[1:])
else:
return False