fork download
  1. import re
  2.  
  3. s = 'A B C D \n EF G'
  4. print(re.sub(r"[^\S\r\n]{2,}", " ", s))
  5.  
Success #stdin #stdout 0.02s 9744KB
stdin
Standard input is empty
stdout
A B C D 
 EF G