isMatch("ab",".*") true, isMatch("ab",".*c") false? Are you Kidding me ?

  • 0

    why the result of isMatch("ab",".*") is ture,but isMatch("ab",".*c") is false, this result confuesed me. help me .

  • 0

    the regular expression .c reads as 0 or more of any character with a c as the last character.
    reads as 0 or more of any character which basically matches anything.

  • 0

    @Su_23 ".*" (i.e., "fuzzy" match) can match string with any length and any chars, so isMatch(s, ".*") is always true for any string s.

    ".*c" contains char c as the last entry which is a concrete match, so isMatch("ab", ".*c") is false.

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.