I want to remove any char which repeats more than two times consecutive.
import re
re.sub(r'([a-z])\1+', r'\1', 'ffffffbbbbbbbqqq')
it's returning me fbq, while I need ffbbqq. The goal is pre-process the string before doing a spell checking. What am I doing wrong?
In [204]: import re
In [205]: re.sub(r'([a-z])\1+', r'\1\1', 'ffffffbbbbbbbqqq')
Out[205]: 'ffbbqq'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With