From: Robert Klemme Date: 2011-07-24T01:03:08+09:00 Subject: Re: regex oddity On Fri, Jul 22, 2011 at 8:41 PM, Roger Pack wrote: > Anybody know why this occurs? > >>> 'a'.scan /.*/ > => ["a", ""] > > Is this normal/expected? Yes. Scanning will start at pos 0 of the string and match as long as it can (i.e. until the end of the string): you get "a". Next, position is increase (now 1, *at* the end) and since .* matches the empty string alas we have a match here as well: "". Next position is *after* the end => no more matches. If you want to see regexp engine matching in action you can use regexp coach which is a nice tool to explore such things (albeit not with ruby's regexp engine). Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/