Possible Duplicate:
Replace multiple whitespaces with single whitespace in JavaScript string
I have used trim function to remove the white spaces at the beginning and end of the sentences. If there is to much white spaces in between words in a sentence, is there any method to trim?
for example
"abc def. fds sdff."
try
or
or use this
allTrimString extension[edit 2023] Pretty old answer. Here is a parser function to remove all multiple spaces (and spaces only, not whitespace) from a string, which removes the need for a regular expression.