正则表达式中的grep辅音 [英] grep consonants in regular expression

查看:90
本文介绍了正则表达式中的grep辅音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用grep查找具有特定数量辅音的单词.但是,使用以下命令将给我连续的辅音,如何修改命令以使非连续的辅音也可以?

I want to use grep to find words that have a specific number of consonants. But using the following command will give me consecutive consonants, How do i modify the command so that non-consecutive consonants are also OK?

grep -iE '[^aeiouy]{3}' filename

推荐答案

grep -iP '^(?=(.*[^aeiouy]){3}).*$' filename

您可以尝试这样做.这将选择在字符串中任何位置至少具有3个辅音的单词.请使用Pperl模式.

You can try this.This will select words which have at least 3 consonants anywhere in the string.Use P or perl mode.

这篇关于正则表达式中的grep辅音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆