fork download
  1. import re
  2. rx = r'\b([A-Z](?:\.[A-Z])+\b(?:\.(?![A-Z]))?)|\.'
  3. s = ' A.B.C.D.E. FGH.IJ K.L.M.NO PQ.R.S T.U.VWXYZ'
  4. print( re.sub(rx, lambda x: x.group(1).replace('.', '') if x.group(1) else ' ', s.strip()) )
Success #stdin #stdout 0.02s 9544KB
stdin
Standard input is empty
stdout
ABCDE FGH IJ KLM NO PQ RS TU VWXYZ