Back to course home
0% completed
Vote For New Content
Solution: Regular Expression Matching
Problem Statement
Given a string text
and regular expression pattern
, return true
if string text
matches with pattern
. Otherwise, return false
.
Follow the below rules to match text
with pattern
.
- '.' matches any
single character
. - '*' matches zero or more occurrences of the
preceding element
.
Examples
-
Example 1:
- Input: text = "abc", pattern = "a.c"
- Expected Output: true
- Justification: The '.' in the pattern matches any character, so "a.c" matches "abc".
-
Example 2:
- Input: text = "aadg", pattern = ".*d."
.....
.....
.....
Like the course? Get enrolled and start learning!
On this page