fork(1) download
  1. import re
  2. text = "This is! ? a test! ?"
  3. print( re.sub(r"(?<=[^\w\s]|_)\s+(?=[^\w\s]|_)", "", text) )
  4.  
Success #stdin #stdout 0.02s 9396KB
stdin
Standard input is empty
stdout
This is!? a test!?