如何查找包含连续元音的行
$(文件名)| sed '/[a*e*i*o*u]/!d'
最佳答案
要查找包含连续元音的行,您应该考虑使用
sed -n '/[aeiou]\{2,\}/p' file
此处,[aeiou]\{2,\}
模式匹配 2 次或更多次出现(\{2,\}
是具有最小出现次数的区间量词设置为 2
) 并且 [aeiou]
是匹配其中定义的任何字符的括号表达式。
-n
抑制输出,p
命令仅打印特定行(即 -n
和 p
仅输出与您的模式匹配的行)。
或者,您可以使用 grep
获得相同的功能:
grep '[aeiou]\{2,\}' file
grep -E '[aeiou]{2,}' file
这是一个 online demo :
s="My boomerang
Text here
Koala there"
sed -n '/[aeiou]\{2,\}/p' <<< "$s"
输出:
My boomerang
Koala there
关于regex - 如何只查找包含两个连续元音的行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52989229/