sed - 仅删除带有元音的单词
我正在尝试删除所有以元音开头的单词,如下所示。我的 sed 命令仅删除第一个带有元音的单词,而不删除任何其他单词。我认为下面的边界标记并使用 g
会捕获所有单词,但它没有这样做。我怎样才能得到所有带有元音的单词?
echo "Always take a Big Apple " | sed -r 's/\b^[AEIOUaeiou]\w*//g'
I am trying to delete all words that start with a vowel as per below. The sed command I have is only deleting the first word if it has a vowel, not any others. I thought the boundary marker below and using the g
would capture all words but it is not doing it. How do I get it to get all words with vowels ?
echo "Always take a Big Apple " | sed -r 's/\b^[AEIOUaeiou]\w*//g'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
删除
^
您不需要将其锚定到行首,足以满足您要求它位于单词边界上的要求。
Remove
^
you don't need to anchor it to the beginning of line, enough that you request it to be on the word boundary.
这个 GNU sed 解决方案可能适合您:
This GNU sed solution might work for you: