import re
def multi_vowel_words(text):
pattern =r"\b\w[aeiou]{3,},?\s?.*\w[aeiou]{3,}.*\b"
result = re.findall(pattern, text)
return result
我做错了什么
运行代码后,我得到以下信息:
[]
['queen is courageous and gracious']
['quietly and await their delicious dinner']
[]
[]
#below this are desired outputs
print(multi_vowel_words("Life is beautiful"))
# ['beautiful']
print(multi_vowel_words("Obviously, the queen is courageous and
gracious."))
# ['Obviously', 'queen', 'courageous', 'gracious']
print(multi_vowel_words("The rambunctious children had to sit quietly and
await their delicious
dinner."))
# ['rambunctious', 'quietly', 'delicious']
print(multi_vowel_words("The order of a data queue is First In First Out
(FIFO)"))
# ['queue']
print(multi_vowel_words("Hello world!"))
# []
print(multi_vowel_words("The order of a data queue is First In First Out
(FIFO)")) # ['queue']
print(multi_vowel_words("Hello world!")) # []
每个人都在使用
\w
来匹配元音的前后字符。这是错误的,因为\w
匹配任何单个字母、数字或下划线(与[a-zA-Z0-9_]
相同)。正确的模式应该是:这会奏效的
试图尝试回答这个问题。用一个简单的模式检查三个连续的元音怎么样
相关问题 更多 >
编程相关推荐