My understanding about ".*"

• Given by the example,

"ab", "."*

it's true.

But I've got:

*Input: "ab", ".c"

Output: true

Expected: false

Do I misunderstand anything?
Thx.

////////

The truth is,

I just confused combining this example,

"aab", "cab" -> true**

and * means zero or more,

so c* can means "", "c","cc","ccc"...

• Both s and p need to be totally matched! not partially matched

Input: "ab", ".c" should return false because "." can match "ab" but "c" have nothing to match.

Input: "aab", "cab" should return false!

• '. *' matches any number of any characters.
For example, 'd. *f' matches any string start with d and end with f, like "deaf" "daaaaf" "df"

• This post is deleted!

• This post is deleted!

• About why "ab" and ".* " will return true:
We know '* ' matches zero or more of the preceding element, so ".*" means we can have zero or more of the '.', so here we can have a string have two '.' like "..", it is obviously matches "ab".

But when input are "ab" and ".*c", the matching can only cover the partial of input string, so it will return false.

• For some reason my * is not showed on screen. I typed * and . , and the pattern is 'd*.f' I am kind of dismayed by the 01 vote.

• basically ".*" can mean ""(empty), "."(one char) , ".."(two char) , "..."(three char), "............."(any char)
it can match any string.

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