From: "Rubén Medellín" Date: 2008-07-24T03:34:44+09:00 Subject: Re: how to capitalize a number of characters in a word class String def capitalize_at(*indices) str = self.dup indices.each do |i| if chr = self[i, 1] str[i,1] = chr.upcase else raise IndexError.new("character #{i} out of index") end end str end end "helloha".capitalize_at(0, 3) # => "HelLoha" If you find yourself doing it frequently.