because . * c means any string that ends with 'c'.
The string "ab" can match ". * " but it doesn't end with 'c', so the match is false.
Thanks for the reply, but there is another test case "aab" and "c *a *b", it says it is true, how can this be possible?
in the regular expression "c *a *b":
"c * " means there is 0 or 1 or multiple 'c'.
"a * " means there is 0 or 1 or multiple 'a'.
And the end of string must be 'b'
"aab" meet above criteria, doesn't it? There is 0 'c', 2 'a', and it ends with 'b'.
Hope it helps.
i'm still confused..
for .* matching ab, let's say '.' gives 'a' then '*' gives 0 or more of its previous character which is 'a'.
how is ab matched?
@leooo.l: the previous character is '.', not 'a'. For ., it means, ''. '.', '..', '...', '...', and any number of '.' So . can match any string.
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.