fork download
  1. import re
  2. p = re.compile(r"(\b[-']\b)|[\W_]")
  3. test_str = "No - d'Ante compactified on a calabi-yau threefold @ ,."
  4. result = p.sub(lambda m: (m.group(1) if m.group(1) else " "), test_str)
  5. print(result)
Success #stdin #stdout 0.01s 9016KB
stdin
Standard input is empty
stdout
No    d'Ante compactified on a calabi-yau threefold