Rokt placement identifiers may use a compact pattern format. Given a pattern s1 and a candidate string s2, determine whether the pattern matches the entire string.
The pattern supports two wildcard forms:
. matches exactly one arbitrary character.d matches exactly d arbitrary characters. Each digit is an independent token, so 23 means two wildcards followed by three wildcards, not twenty-three.Return True only when the complete pattern matches the complete candidate string. Return False otherwise.
s1 and s2 containing lowercase letters, digits, and . in s1, and lowercase letters in s2.s1 matches all of s2.Example 1
Input: s1 = "r.kt", s2 = "rokt"
Output: True
The . consumes o, leaving r, k, and t to match exactly.
Example 2
Input: s1 = "a3d", s2 = "axyzd"
Output: True
The digit 3 consumes xyz.
Example 3
Input: s1 = "r2k", s2 = "rokt"
Output: False
After r2 consumes rok, the remaining character is t, not k.
.def matches_pattern(s1, s2):