I think what you're looking for is JavaScript's string.replace() method.
If you want all whitespace removed, use this:
"abc def. fds sdff.".replace(/\s/g, '');
Returns: "abcdef.fdssdff."
If you want only double-spaces removed, use:
"abc def. fds sdff.".replace(/\s\s/g, ' ');
Returns: "abc def. fds sdff."
If you want the space left after a period, use:
"abc def. fds sdff.".replace(/[^.]\s/g, '')
Returns: "abcdef. fdssdff."