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?