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
c2bd6bf9a2
commit
7271e3d2a5
@ -30,11 +30,8 @@ def recursive_match(text: str, pattern: str) -> bool:
|
||||
>>> recursive_match('aa', '.*')
|
||||
True
|
||||
"""
|
||||
if not text and not pattern:
|
||||
return True
|
||||
|
||||
if text and not pattern:
|
||||
return False
|
||||
if not pattern:
|
||||
return not text
|
||||
|
||||
if not text:
|
||||
return pattern[-1] == "*" and recursive_match(text, pattern[:-2])
|
||||
|
Loading…
x
Reference in New Issue
Block a user