Here’s a potential solution that utilizes a recursive method in Python: def isMatch(text, pattern): if not pattern: return not text first_match = bool(text) and pattern[0] in {text[0], '.'} if len(pattern) >= 2 and pattern[1] == '*': return (isMatch(text, pattern[2:]) or # * signifies zero occurrences of the preceding element first_match and isMatch(text[1:], pattern)) # * signifies one or more occurrences of the preceding element else: return first_match and isMatch(text[1:], pattern[1:]) # matches the first character This solution begins by checking if the pattern is empty. If it is, then if the text is also empty, it indicates a match, so it returns not text, which would evaluate to True if the text is empty. If the pattern is not empty, it compares the first character of both the pattern and the text. If they are the same or if the first character of the pattern is '.', it sets the first_match flag to True.