import rerx = r"\s*(\.{3}|\.)\s*"s = "This is... a test."print(re.sub(rx, r" \1 ", s).strip())
Standard input is empty
This is ... a test .
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!