Why "aab" "a*bc" returns false??

  • 0

    In the example, "aab", "c*a*b" is true;
    When I tried "aab", "c*a*b*c", it returns false. I thought it should be true.
    I cannot understand...
    Could anyone please explain to me?

    The same for this example:

    I think this should return true; But the online judge return false.

  • 0

    aab c*a*b
    c*a*b最后相当于 c0a1b (aab),所以能匹配
    但是 c*a*bc相当于 c0a1bc (aabc),所以无法匹配。


  • 0

    c* matches the 0 c's that start the string
    a* matches aa
    b* matches b
    The string doesn't end with c so it doesn't match the last part of the regex

Log in to reply

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