Given a string like:
\"The dog has a long tail, and it is RED!\"
What kind of jQuery or JavaScript magic can be used to keep spaces to only o
var str = "The dog has a long tail, and it is RED!"; str = str.replace(/ {2,}/g,' ');
EDIT: If you wish to replace all kind of whitespace characters the most efficient way would be like that:
str = str.replace(/\s{2,}/g,' ');