简体   繁体   English

相邻相同字符的正则表达式

[英]regular expression for adjacent same character

I'm looking for a regular expression pattern that can match adjacent 2 same characters, (used for grepping in Linux).我正在寻找可以匹配相邻 2 个相同字符的正则表达式模式(用于 Linux 中的 grepping)。 For example: Catt Puppet Worry Fool例如:Catt Puppet Worry Fool

Something like this with GNU grep?与 GNU grep 类似的东西?

echo 'Catt Puppet Worry Fool' | grep -E '(.)\1'

or或者

echo 'Catt Puppet Worry Fool' | grep -oE '(.)\1'

Update:更新:

Try this to get the complete words:试试这个以获得完整的单词:

echo 'Catt Puppet Worry Fool' | grep -Po '[^ ]*(.)\1[^ ]*'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM