From: "SHULTZ,BARRY (HP-Israel,ex1)" Date: 2002-11-03T18:04:00+09:00 Subject: Re: substitution problem 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