From: James Edward Gray II Date: 2006-01-04T07:51:55+09:00 Subject: Re: silly regex question On Jan 3, 2006, at 4:41 PM, Joe Van Dyk wrote: > IMO, my version's more readable. I'm going for readability here. def process_string str result = Hash.new str.scan(/^\s*(important ([a-zA-Z0-9]+): .+?)\s*$/) do |line, key| result[key] = line end result end # ... or ... def process_string str str.inject(Hash.new) do |result, line| result[$1] = line if line =~ /^\s*important ([^:]+):/ result end end James Edward Gray II