From: Brian Candler Date: 2012-12-07T23:49:38+09:00 Subject: Re: Trying to get "translator" to work I got lost trying to decode your logic for two consonants, three consonants etc, so here is a simple implementation of the rules from Wikipedia instead. def translate(words) words.gsub(/\w+/) do |word| case word # In words that begin with consonant sounds, the initial consonant or # consonant cluster is moved to the end of the word, and "ay" is added. # Note that "qu" is treated as a consonant sound. when /^((b|c|d|f|g|h|j|k|l|m|n|p|qu|r|s|t|v|w|x|y|z)+)(.*)/i "#{$3}#{$1}ay" # In words that begin with vowel sounds or silent consonants, the initial # vowel is removed and the syllable "way" added to the end of the word # FIXME: silent consonants are not considered here. when /^[aeiou]+(.*)/i "#{$1}way" else word end end end puts translate("pig computer happy question another about quale square") You may find the above rather terse for your liking, but it boils down to "if the word matches this pattern, then rebuild it using the captured parts like this". It's an example of the power and brevity of ruby :-) -- Posted via http://www.ruby-forum.com/.