Tag: remove method

如何删除Ruby中字符串中的最后一个元音?

如何在字符串中定义-last元音? 例如,我有一个单词“经典” 我想找到“classs i c”这个词的最后一个元音是字母“ i ”,并删除最后一个元音。 我在想 : def vowel(str) result = “” new = str.split(” “) i = new.length – 1 while i < new.length if new[i] == "aeiou" new[i].gsub(/aeiou/," ") elsif new[i] != "aeiou" i = -= 1 end end return result end