text and a pattern pattern. Besides lowercase English letters, the pattern may contain two special characters:
- . matches any single character;
- * means the character right before it may repeat any number of times, including zero.
Return True if the pattern matches the whole of text (not just part of it), and False otherwise.text="moon", pattern="mo*n" → True
o* takes both letters o, and the remaining characters match.
text="cat", pattern="c." → False
c. describes exactly two characters, but the text has three, and the pattern must cover all of it.
text="bx", pattern="a*b.*" → True
a* takes nothing, b matches b, and .* absorbs the x.
text consists of lowercase English letterspattern consists of lowercase English letters, . and ** is preceded by a letter or .text="moon", pattern="mo*n"
True
Run checks the first 3 tests in your browser. Submit checks all 136 tests on the server, hidden ones included.