From: Daniel Bretoi Date: 2002-11-03T16:32:37+09:00 Subject: Re: substitution problem btw, I have this solution, but I'd like to know the thory why my other solution didn't work bits = str.split('\s') for b in bits b.capitalize! end str = bits.join(' ') On Sun, Nov 03, 2002 at 04:18:20PM +0900, Daniel Bretoi wrote: > Hi All, > > 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? > > db > -- > A.D. 1844: Samuel Morse invents Morse code. Cryptography export > restrictions prevent the telegraph's use outside the U.S. and Canada. -- A.D. 1844: Samuel Morse invents Morse code. Cryptography export restrictions prevent the telegraph's use outside the U.S. and Canada.