正则表达式未产生预期输出
我正在制作一个简单的正则表达式来识别第一个辅音(如果有),然后识别中间的所有元音,然后识别最后一个元音之后的下一个辅音(如果有)。
例如:
we are all morons -->> we ae al moon
我写了这个表达式,但它并不在所有情况下都有效。
请指教。
"[^aeiou]?[aeiou]+[aeiou]?"
不知道我哪里出错了。
I am making a simple regular expression to recognise first consonant(if any),then all the vowels in between and then the next consonant after the last vowel(if any).
For ex:
we are all morons -->> we ae al moon
I wrote this expression but it doesn't work in all situations.
Please advise.
"[^aeiou]?[aeiou]+[aeiou]?"
Not sure where I am getting wrong.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要使用非捕获组,以便匹配不会停止。现在您只匹配与您所需的输出相匹配的单词。请参阅:什么是非捕获组?问号后跟冒号 (?:) 是什么意思?
了解更多信息。
You need to use non capturing groups so the matching wont halt. Now you are matching only words that matches your desired output. see : What is a non-capturing group? What does a question mark followed by a colon (?:) mean?
for more information.