I would like to remove all the "unnecessary" spaces from a string. Specifically:
"a b c d" => "a b c d" // spaces between two words are left in
" a b c d " => "a b c d" // spaces not between two words are removed
"a b c d" => "a b c d" // as are duplicate spaces
Is there any regex out there that I can put into String.replace()
to do this for me?