> > It's because the pattern /.*/ matches everything, including the
> > absence of everything.
>
> > So: since * matches "zero or more" characters when it starts the
> > search for .* it matches the absence (the 'zero') and then matches the
> > string (the 'or more').
>
> It's the other way around, though; it matches "hello" *first*, and
> then "".  So the zero-matching (which I admit I'm among those who find
> unexpected) is happening at the end.

Oh right, I think I get it now. If you try to match anything with *
then a match is guaranteed, because if there's nothing to match, then
you'll just match nothing?

Like this:

irb(main):001:0> "hello".scan(/h*/)
=> ["h", "", "", "", "", ""]

And this:

irb(main):002:0> "hello".scan(/P*/)
=> ["", "", "", "", "", ""]


I've always assumed, and used, .* to make everything before,
but I suppose .+ does make more sense. Although I have to say
I still find it a bit odd...

Thanks everyone for your help.