I have:
var str = 'ddd';
var r = /d*/g;
console.log(str.match(r))
the output in my console is an array of two; first is a string containing 'ddd' and second its a empty string. I know what * means (0 or more) but why it outputs that empty string? I would expect to ouptut just one string 'ddd' . Once it matches for d key, why it just continue with that empty string?
If I call without the g flag, it outputs what I really expected to do with it.
I also know that g means, global search, it iterates through all elements of str, but how that, when my search was completed by the first match?
*to a+if you do not want a zero match?