regex to match repeated consonant

后端 未结 6 1767
悲&欢浪女
悲&欢浪女 2021-02-04 03:28

How can I detect with a regex expression if the same consonant is repeated three times or more?

My idea is to match words like tttoo

6条回答
  •  执笔经年
    2021-02-04 03:41

    Try this:

    ([b-df-hj-np-tv-z])\1{2,}
    

    Explanation:

    • [b-df-hj-np-tv-z] are all the consonants
    • \1 is the back reference to the 1st group (ie the same character)
    • {2,} means "2 or more of the preceding term", making 3 or more in all

    See live demo.

提交回复
热议问题