fork(2) download
  1. import re
  2.  
  3. text = "Hello, world. I'm a boy, you're a girl."
  4. replaced = re.sub('\S+', lambda m: re.sub('^\W+|\W+$', '', m.group()), text)
  5. print(replaced)
Success #stdin #stdout 0.03s 9936KB
stdin
Standard input is empty
stdout
Hello world I'm a boy you're a girl