From: Axel Etzold Date: 2007-06-21T07:49:45+09:00 Subject: Re: Do You Understand Regular Expressions? > 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. You can search for at least one occurrence like this: "hello".scan(/.+/) "hello".gsub(/.+/, "P") => 'P' As an introduction, I find http://www.regular-expressions.info/ruby.html quite instructive for the use of regexps in Ruby. Best regards, Axel -- Psssst! Schon vom neuen GMX MultiMessenger geh�rt? Der kanns mit allen: http://www.gmx.net/de/go/multimessenger