1. 首页
  2. 数据库
  3. 其它
  4. 正则表达式匹配

正则表达式匹配

上传者: 2020-12-23 03:50:18上传 PDF文件 144.71KB 热度 51次
回溯 我理解的就是递归,一直在判断“*”的存在,最后递归得出结果 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)
下载地址
用户评论