fork download
  1. import re
  2. s = "i'm sorry, sir, but this is a 'gluten-free' restaurant. we don't serve bread."
  3. print( re.sub(r"(?:(?!\b['‘’]\b)[\W_])+", ' ', s).strip() )
Success #stdin #stdout 0.04s 9500KB
stdin
Standard input is empty
stdout
i'm sorry sir but this is a gluten free restaurant we don't serve bread