From: Jens Wille Date: 2008-04-10T07:06:45+09:00 Subject: Re: capitalizing words Peter Bailey [2008-04-09 20:04]: > output = file.gsub(%r{^( face="b">)(.*)(<\/emph>)}m) do |match| > "#{$1}#{$2.gsub(%r{\b\w+\b}){|w|w.capitalize}}#{$3}" > end oh, and for the fun of it, here's what you can do with oniguruma: Oniguruma::ORegexp.new( '(?<=^).+(?=)', 'm' ).gsub(file) { |md| md[0].gsub(%r{\b\w+\b}) { |w| w.capitalize } } (note that i needed to change '.*' to '.+') cheers jens