正则表达式匹配

zhangwei11288 35 0 PDF 2020-12-23 03:12:18

回溯 我理解的就是递归,一直在判断“*”的存在,最后递归得出结果 class Solution: def isMatch(self, s: str, p: str) -> bool: if not p: return not s f= bool(s and p[0] in {s[0],'.'}) if len(p) >= 2 and p[1] == "*": return self.isMatch(s, p[2:]) or f and self.isMatch(s[1:], p)

用户评论
请输入评论内容
评分:
暂无评论