From: Daniel Bretoi Date: 2002-11-04T03:23:16+09:00 Subject: Re: substitution problem Thanks guys, Barry, I like yours the best as it's closet to mine and because you're not using capitalize. Capitalize actually changes all other letters in a word to be lowercase, which isn't always desired. Thanks very much all. db On Sun, Nov 03, 2002 at 06:04:00PM +0900, SHULTZ,BARRY (HP-Israel,ex1) wrote: > Hi, > > > > I'd like to capitalize every word in a string. > > > > > > I was hoping this expression would do it: > > > > > > newstr = str.gsub(/\b(\s)?([a-z])/,'\1\2'.upcase) > > > > > > but it turns out that as \2 is not evaluated right away, > > the .upcase has > > > no effect. Suggestions? > > > > > > > how 'bout the block form? > > newstr = str.gsub(/\b(\s)?([a-z])/) { |s| s.upcase } > > that works for me. > > Regards, > Barry > -- A.D. 1844: Samuel Morse invents Morse code. Cryptography export restrictions prevent the telegraph's use outside the U.S. and Canada.