Tuesday, 17 September 2013

Trying to use $ holders to capitalize the first letter of each sentence in a regular expression

Trying to use $ holders to capitalize the first letter of each sentence in
a regular expression

so I'm stumped. I've been looking at this for a couple days now and
honestly it's probably a very easy fix since I am new to this
I have string like the following example>>
THiS is a Li?ne of text
!THiS is a Line of text
((THiS is a Line of text.X
THiS is a Line of text
and I want to capitalize each line but keep it in orginal form so far I have
puts the_string.gsub(/(^\W*?)([a-z])/) { |x| "#{$2.capitalize}"}
But this gets rid of the whitespace :( please help

No comments:

Post a Comment