mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-02-25 10:28:39 +00:00
Update dynamic_programming/regex_match.py
Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
This commit is contained in:
parent
b87b9a819f
commit
c2bd6bf9a2
@ -36,11 +36,8 @@ def recursive_match(text: str, pattern: str) -> bool:
|
||||
if text and not pattern:
|
||||
return False
|
||||
|
||||
if not text and pattern and pattern[-1] != "*":
|
||||
return False
|
||||
|
||||
if not text and pattern and pattern[-1] == "*":
|
||||
return recursive_match(text, pattern[:-2])
|
||||
if not text:
|
||||
return pattern[-1] == "*" and recursive_match(text, pattern[:-2])
|
||||
|
||||
if text[-1] == pattern[-1] or pattern[-1] == ".":
|
||||
return recursive_match(text[:-1], pattern[:-1])
|
||||
|
Loading…
x
Reference in New Issue
Block a user