I think this may be a fairly simple and strict forward question but i cannot figure out the reason. Please kindly help.
"hello".match(/e*/) //return [""]
"hello".match(/e+/) //return ["e"]
It matched, or you would be getting
null as a result.
The match is zero characters right at the beginning of the string. Your assertion is "find a place in the string where there is zero or more of
e": Right at the start of the
hello, there is zero or more of
e, so we don't need to search further.
match expectedly returns
[""] (the zero characters matched).
On the other hand,
/e+/ wants one or more
e characters; this is not satisfied at the start of the string, but it is satisfied at the very next position, and you get