Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我开始研究正则表达式,我一直想知道如何在 UNIX 表示法中为包含子字符串“ai”或“ui”的所有元音字符串构建和测试正则表达式。
会不会是这样的: (ai|ui) ?我怎么能测试它?
IIUC,你想要类似 '^[aeiou]*?(ai|ui)[aeiou]*$'. 例子:
'^[aeiou]*?(ai|ui)[aeiou]*$'
$ echo aaauiaa | grep -E '^[aeiou]*?(ai|ui)[aeiou]*$' aaauiaa $ echo aaaaiaa | grep -E '^[aeiou]*?(ai|ui)[aeiou]*$' aaaaiaa