Setting up Python Regex for replacing double consonnats with one consonant

I have some difficulty with regex that “replaces all double consonants with single consonants”
Example:

“Sally” => needs to be changed to " Saly "
“rabbit” => needs to be changed to " rabit "

I came up with this regex ([^aeiou])\1 that captures the double ll in “Sally” and the double bb in “rabbit” but I am finding very hard to figure out how change the double ’ ll’ in Sally to Saly (with one ‘l’).

Program setup:

#word = 'Sally'
#word = 'rabbit'

m = re.sub(r'h|H[^y][bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ]', '', word)

print (m)

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.