isMatch("ab", ".*") → true

  • 1

    How come this test case is true ?

    as . will get matched to 'a' and then * as the description says, Matches zero or more of the preceding element. In this case that is 'a'(previously matched character), so '*' shouldn't get matched to b at all.

    isMatch("aa", ".*") = true, this test case makes the right sense, I believe.

  • 0

    As far as I understand '*' after dot '.' indicates zero or more '.'. This is a common use case in regex to indicate arbitrary character in arbitrary length.

  • 0

    This means its logical interpretation is just '*' then.

  • 0

    @cipherbowen I saw different conventions in regex.
    If '.*' is the convention to indicate arbitrary chars.
    How do people represents the following pattern in such convention?
    "the same char repeated in any times "


Log in to reply

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