正则表达式匹配重复三遍的字符 [英] Regular expression to match character repeated three times
本文介绍了正则表达式匹配重复三遍的字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要简化以下正则表达式以包含字母表中的所有字母:
I need to simplify the following regular expression to include all the letters of the alphabet:
(a{3})|(b{3})|(c{3})|(z{3})|(A{3})|(B{3})|(C{3})|(Z{3})
实际上我想找到相同三个字符的所有序列,例如:
In practice I want to find all the sequences of same three chars, for example:
aaa
bbb
nnn
VVV
JJJ
等等.
推荐答案
使用反向引用.例如.在 sed 中:
Use backreferences. Eg. in sed:
\([a-zA-Z]\)\1\1
或在 PERL 正则表达式中
or in PERL regular expressions
([a-zA-Z])\1\1
这篇关于正则表达式匹配重复三遍的字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文