fork(1) download
  1. import re
  2. rx = re.compile(r'''[][!":$()',]|(\d+)''')
  3. sentence = ['cracked $300 million','she\'s resolutely, smitten ', 'that\'s creative [r]', 'the market ( knowledge check : prices up!']
  4. s = [rx.sub(lambda x: '£' if x.group(1) else ' ', word) for word in sentence]
  5. print(s)
  6.  
Success #stdin #stdout 0.03s 9484KB
stdin
Standard input is empty
stdout
['cracked  £ million', 'she s resolutely  smitten ', 'that s creative  r ', 'the market   knowledge check   prices up ']