From 7271e3d2a51e9a7177967fa40e68a20fbbaba2d2 Mon Sep 17 00:00:00 2001 From: Amir Hosseini <19665344+itsamirhn@users.noreply.github.com> Date: Mon, 14 Aug 2023 08:07:37 +0330 Subject: [PATCH] Update dynamic_programming/regex_match.py Co-authored-by: Tianyi Zheng --- dynamic_programming/regex_match.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/dynamic_programming/regex_match.py b/dynamic_programming/regex_match.py index efe7cce9e..6e5a3805a 100644 --- a/dynamic_programming/regex_match.py +++ b/dynamic_programming/regex_match.py @@ -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])