Cleanly paste badly formatted text

Problem: Copying and pasting from a PDF document or similar can often leave lots of newlines all over the place, as well as multiple space characters in between words.

Solution: The following small AutoHotKey script cleans whatever is on the clipboard, removing all newlines, and ensuring that there is just one space between words, two spaces after a fullstop.  It is bound to Win-b.

#b::
a := RegExReplace(clipboard, "\r\n", " ")
a := RegExReplace(a, "(?<=\.) +", "  ")
a := RegExReplace(a, "(?>!\.) +", " ")
clipboard = %a% 
send ^v
send {Enter}
return