You can trim multiple consecutive spaces down to only one space with this Javascript:
var str = "abc def. fds sdff.";
str = str.replace(/\s+/g, " ");
If you meant something other than multiple consecutive spaces, then please clarify in your question what you meant.