我试图确定一个单词是否以元音、一个辅音、两个辅音或三个辅音开头。这是我到目前为止所拥有的,但我无法让它发挥作用。
def vowel_first(word)
word[0] =~ /[aeiou]/
end
def consonant_first_three(word)
word[0-2] =~ /^[^aeiou]{3}/
end
def consonant_first_two(word)
word[0-1] =~ /[^aeiou]{2}/
end
def consonant_first(word)
word[0] =~ /[^aeiou]{1}/
end