import re
s = '-h--ee---l--ll--o--'
p = re.compile(r"([0-9a-zA-Z])(\1+)")
out_s = re.sub('-', '', p.sub(r'\1', s)) # 'hello'
import re
s = '-h--ee---l--ll--o--'
p = re.compile(r"([0-9a-zA-Z])(\1+)")
out_s = re.sub('-', '', p.sub(r'\1', s)) # 'hello'