regex to match repeated consonant

后端 未结 6 1771
悲&欢浪女
悲&欢浪女 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:44

    There may be shortcuts in certain regex libraries but you can always...

    b{3,}|c{3,}|d{3,}...
    

    Some libs for example let you match using a back reference which may be a tad cleaner...

    (bcd...)\1{2,}
    

提交回复
热议问题