From: Ryan Mckenzie Date: 2011-07-26T06:56:14+09:00 Subject: Re: Splitting strings Ah yes I see what you mean now. Ok so now I'm left with trying to use the hash key to assign the phrases. Do I need to incrument the h and k each time or just one of them? lists = Hash.new {|h, k| h[k] = []} f.each do |line| phrase = line.scan /\w+/ limit = phrase.length - 1 0.upto limit do |start| start.upto limit do |stop| lists[h,k] << [start..stop].join(' ') end end end lists.sort_by {|w,c| -c}.each do |w,c| printf "%6d %s\n", c, w end Thanks again, Ryan -- Posted via http://www.ruby-forum.com/.