From: "SHULTZ,BARRY (HP-Israel,ex1)" <barry.shultz / hp.com>

> 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.

Or

  newstr = str.gsub(/\w+/) { |s| s.capitalize }

> Regards,
> Barry

Gavin