s*****p 发帖数: 26 | 1 求问为啥这组test case是对的?
isMatch("ab", ".*") ? true
请赐教! | J****3 发帖数: 427 | 2 It seems that some readers are confused about why the regex pattern ".*"
matches the string "ab". ".*" means repeat the preceding element 0 or more
times. Here, the "preceding" element is the dot character in the pattern,
which can match any characters. Therefore, the regex pattern ".*" allows the
dot to be repeated any number of times, which matches any string (even an
empty string). | s*****p 发帖数: 26 | 3
the
恍然大悟啊!
【在 J****3 的大作中提到】 : It seems that some readers are confused about why the regex pattern ".*" : matches the string "ab". ".*" means repeat the preceding element 0 or more : times. Here, the "preceding" element is the dot character in the pattern, : which can match any characters. Therefore, the regex pattern ".*" allows the : dot to be repeated any number of times, which matches any string (even an : empty string).
|
|