fork download
  1. import ast, re
  2. X= """["This is an hairy #calf",
  3. "goodbye to the snow #gone",
  4. "13742 the digits to give",
  5. "Remember the name d - mayne",
  6. "I hate you"]"""
  7. l = ast.literal_eval(X)
  8. rx_non_word = re.compile(r'[^\w\s]+')
  9. rx_white = re.compile(r'\s{2,}')
  10. print ( "\n".join([rx_white.sub(' ', rx_non_word.sub('', x)) for x in l]) )
Success #stdin #stdout 0.02s 9960KB
stdin
Standard input is empty
stdout
This is an hairy calf
goodbye to the snow gone
13742 the digits to give
Remember the name d mayne
I hate you