【发布时间】:2020-06-06 15:44:06
【问题描述】:
我正在尝试创建一个函数来从以下字符串中提取具有 3 个连续元音的单词
import re
def three_vowel_words(text):
pattern = "[\w]+[aeiou]{3}"
result = re.findall(pattern, text)
return result
print(three_vowel_words("Our team was victorious over theirs in the contest."))
#the output should be ["victorious"]
print(three_vowel_words("Obviously, the acquaintance is serious and ambitious."))
#the output should be ["Obviously","acquaintance","serious","ambitious"]
但是我得到的输出如下:
["victoriou"]
["Obviou", "acquai", "seriou", "ambitiou"]
谁能帮我纠正我的正则表达式模式,以便提取完整的单词。
谢谢。
【问题讨论】: