【发布时间】:2016-04-06 00:24:25
【问题描述】:
我正在使用从这个问题Regular expression to match any character being repeated more than 10 times获得的解决方案
您需要的正则表达式是 /(.)\1{9,}/.
https://regex101.com/ 正在识别它,grep 识别它,但 python 没有。
最后我想用单个空格替换匹配,例如:
>> text = 'this is text???????????????'
>> pattern = re.compile(r'/(.)\1{5,}/')
>> re.sub(pattern,'\s',text)
'this is text '
但是,search、findall,甚至match 都无法识别该模式,知道为什么吗?
【问题讨论】:
-
Pythex.org 是你的朋友
标签: python regex python-3.x