From: "Kroeger, Simon (ext)" Date: 2006-03-13T22:34:06+09:00 Subject: Re: Quickest way to do this string op. > -----Original Message----- > From: Carlos [mailto:angus@quovadis.com.ar] > Sent: Monday, March 13, 2006 2:31 PM > To: ruby-talk ML > Subject: Re: Quickest way to do this string op. > > eastcoastcoder@gmail.com wrote: > > > What's the quickest way to turn "BOCA RATON" into "Boca Raton"? > > "BOCA RATON".replace "Boca Raton" # :-P > > Probably > > "BOCA RATON".split(/\b/).map{|s| s.capitalize }.join > > It is quick to write, at least... > > HTH "BOCA RATON".gsub(/\w+/){|w| w.capitalize} is even shorter :) cheers Simon