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


  • 0
    L

    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?
    Thanks.

    The same for this example:
    "aab"
    "a*bc"

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


  • 0
    L

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

    *可以表示0个字符,相当confusing


  • 0
    J

    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.