Regular Expression Matching
Return whether the entire string s matches pattern p. A dot matches one character; a star repeats the preceding literal or dot zero or more times. No other regex features exist.
Example 1
s = "aab"
p = "c*a*b"trueExplanation
c uses zero c letters, a uses two a letters, and b consumes the final b.
Example 2
s = "ab"
p = ".*"trueExplanation
.* consumes both a and b because dot matches either.
Example 3
s = "aaa"
p = "a"falseExplanation
The literal a cannot consume all three characters; partial matching is insufficient.
Example 4
s = ""
p = "a*"trueExplanation
a* repeats zero times to match the empty string.
Constraints
- 0 <= len(s),len(p) <= 20
- s is lowercase
- p contains lowercase letters, dots and stars
- Each star has a valid preceding atom
Function contract
isMatchArguments: json, jsonSolutionRuns on your device
Loading draft…
Run: 3 examples; Submit: 33 cases, on your device.
"aab""c*a*b"