fork download
  1. import re
  2. words = ["That's", 'a-', 'tasty', 'tic-tac.','Or', '-not?']
  3. rx = re.compile(r"\b([-'])\b|[\W_]")
  4. print( [rx.sub(r'\1', x) for x in words] )
Success #stdin #stdout 0.02s 9576KB
stdin
Standard input is empty
stdout
["That's", 'a', 'tasty', 'tic-tac', 'Or', 'not']