我正在尝试创建一个RegEx来查找包含任何元音的单词。到目前为止,我已经尝试过
/(.*?\S[aeiou].*?[\s|\.])/i
但我没有使用RegEx太多,因此无法正常工作。例如,如果我输入“ test is 1234 and sky fly test1234”,则它应该匹配test,is和test1234,但显示test,is1234;如果输入其他内容,则输出不同。
另外,您还可以执行以下操作:
"test is 1234 and sky fly test1234".split.find_all { |a| a =~ /[aeiou]/ }
# => ["test", "is", "and", "test1234"]
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句