From: Richard Powell Date: 2011-02-10T15:30:23+09:00 Subject: Re: capitalizing first letter in each line of a string. --0-1789940249-1297319104=:60373 Content-Type: text/plain; charset=us-ascii thanks! ________________________________ From: Peter Zotov To: ruby-talk ML Sent: Wed, February 9, 2011 12:44:50 PM Subject: Re: capitalizing first letter in each line of a string. On Thu, 10 Feb 2011 05:32:50 +0900 Richard Powell wrote: > Hi, > Im in need of capitalizing first letter of each line in a long > string, and have it print exactly the same (but with the first word > capitalized+with the whitespace).. but cant figure it out.. any > advise? > > taco = <<-HERE > to bad I hate tacos they taste great.. > so much for a HEALTHY diet.... > > HERE > > taco.scan(/\W+\.*\w+\.*/){|x| print x.capitalize} > > ______ > > im guessing my regular expression is wrong. and possibly > the .capitalize is in the wrong space? > sorry im a newbie :) > thanks > rich Here you are: taco = <<-HERE to bad I hate tacos they taste great.. so much for a HEALTHY diet.... HERE p taco.gsub(/^(\W*?[a-z])/) { |m| m.upcase } -- WBR, Peter Zotov --0-1789940249-1297319104=:60373--