From: "Jan E." Date: 2012-06-07T17:48:38+09:00 Subject: Re: string character count "Jesús Gabriel y Galán" wrote in post #1063418: > > 1.9.2p290 :001 > s = "this is a string." > => "this is a string." > 1.9.2p290 :002 > s.split(" ").map {|x| x.length}.join(" ") > => "4 2 1 7" Or shorter: s.split.map(&:length).join ' ' Or even shorter and more robust (will handle any sequence of any space characters): s.gsub /\S+/, &:length However, this is also slower. -- Posted via http://www.ruby-forum.com/.