From: Jens Wille Date: 2008-04-10T04:56:30+09:00 Subject: Re: capitalizing words Rob Biedenharn [2008-04-09 20:46]: > head, content, tail = $1, $2, $3 > "#{head}#{content.gsub(%r{\b\w+\b}){|w|w.capitalize}}#{tail}" now here's a quick implementation that passes the MatchData object into the block: so that code effectively becomes: str.gsub_with_md(re) { |md| "#{md[1]}#{md[2].gsub(%r{\b\w+\b}){|w|w.capitalize}}#{md[3]}" } ;-) cheers jens