isMatch(“ab”, “.*”) → 1


#1

isMatch(“ab”, “.*”) → 1
can anyone explain why it is true?


#2

any answers for this one???


#3

Since . is matching of any character once, this(.*) regex say repeat of any character zero or more then zero times.


#5

.*
ab

when we encounter * :

It means we could replace it with preceding element ( ‘.’ ) multiplied any number of time, that is either no preceding element " “, or 1 (”.") or 2 ("…") or any number of preceding elements.

ab
.*
  1. Here we match “a” with “.”
  2. Then we see a “*” !
    Now we have power to replicate the previous pattern element.
    We replicate “.” once !
    Now we match “b” with “.” !

So the string matches and the answer is yes.