Capitalizing first letter in each line of a string

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 :slight_smile:
thanks
rich

____________________________________________________________________________________
Don't pick lemons.
See all the new 2007 cars at Yahoo! Autos.

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 }

···

On Thu, 10 Feb 2011 05:32:50 +0900 Richard Powell <richpowell@yahoo.com> 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 :slight_smile:
thanks
rich

--
  WBR, Peter Zotov

thanks!

···

________________________________
From: Peter Zotov <whitequark@whitequark.org>
To: ruby-talk ML <ruby-talk@ruby-lang.org>
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 <richpowell@yahoo.com> 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 :slight_smile:
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