matching 3 or more of the same character in python

后端 未结 2 1159
予麋鹿
予麋鹿 2021-02-14 17:11

I\'m trying to use regular expressions to find three or more of the same character in a string. So for example: \'hello\' would not match \'ohhh\' would.

I\'ve tried doi

2条回答
  •  半阙折子戏
    2021-02-14 18:01

    (\w)\1{2,} is the regex you are looking for.

    In Python it could be quoted like r"(\w)\1{2,}"

提交回复
热议问题