Mega Code Archive

 
Categories / Ruby / String
 

Translation from one set of characters to another

puts "hello".tr("aeiou", "AEIOU")  # => "hEllO": capitalize vowels. Also tr! puts "hello".tr("aeiou", " ")      # => "h ll ": convert vowels to spaces