From: Robert Klemme Date: 2009-06-05T05:50:05+09:00 Subject: Re: How to capitalize first word of a string? On 04.06.2009 21:41, Rails List wrote: > I have a string that I would like to capitalize and add bold html tag to > the first word only. How do i do it?. Do I have to split first and > then "upcase!" it then join again. Not sure how to do it. any help is > much appreciated. thanks Do you mean irb(main):003:0> words = "foo bar baz" => "foo bar baz" irb(main):004:0> words.sub(/\w+/) {|m| "#{m.upcase}"} => "FOO bar baz" irb(main):005:0> words.sub(/\w+/) {|m| "#{m.capitalize}"} => "Foo bar baz" irb(main):006:0> Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/