fork download
  1. import re
  2. text = r"Lorem-Ipsum is simply dummy text of-the printing and typesetting industry. abc123-xyz 1abcc-xy-ef apple.pear-banana asdddd-abc-cba"
  3. print(re.sub(r'(?<!\S)[a-zA-Z]+(?:-[a-zA-Z]+)+(?!\S)', lambda x: x.group().replace('-', ' '), text))
Success #stdin #stdout 0.03s 9692KB
stdin
Standard input is empty
stdout
Lorem Ipsum is simply dummy text of the printing and typesetting industry. abc123-xyz 1abcc-xy-ef apple.pear-banana asdddd abc cba