Axel Etzold wrote:
>> irb(main):001:0> "hello".scan(/.*/)
>> => ["hello", ""]
>>
>> I was expecting one match, not two, because .* matches everything,
>> right? Can someone explain why an empty string is also matched?
> 
> String.scan searches for all occurrences of (any number of any 
> character) here. So zero occurrences is one match.

That doesn't really explain why the regexp finds an extra empty string. 
I know that zero occurrences is one match but after a greedy match that 
matches everything, there should be (logically?) no other match. I am no 
stranger to regexps and the result is counter-intuitive to me; I would 
consider it a bug. Or at least a very very peculiar behavior.

Daniel