fork download
  1. import re
  2.  
  3. text = "c-c-c-c-come oh-oh-oh-oh it's a bad life oh-oh-oh-oh"
  4. pattern = r"(?<!\S)(\w{1,3})(?:-\1)*-(\w+)(?!\S)"
  5. text = re.sub(pattern, r'\2', text)
  6. print(text)
Success #stdin #stdout 0.01s 27712KB
stdin
Standard input is empty
stdout
come oh it's a bad life oh