我写的表达是:
^[AEIOUaeiou]{2}.*ing$
Run Code Online (Sandbox Code Playgroud)
我想要搜索的是任何长度的单词,以两个元音开头,以字符串"ing"结尾,有人可以帮我看看我的错误吗?
谢谢.
基本grep使用BRE或基本正则表达式兼容性.在BRE中,你需要逃避花括号,以使大括号像重复量词一样.
grep '^[AEIOUaeiou]\{2\}.*ing$' file
Run Code Online (Sandbox Code Playgroud)
例:
$ cat file
Ooing
Aaing
fooing
$ grep '^[AEIOUaeiou]\{2\}.*ing$' file
Ooing
Aaing
Run Code Online (Sandbox Code Playgroud)