string = string.replace(/ +/g," "); for just spaces OR
string = string.replace(/(\s)+/g,"$1"); for turning multiple returns into a single return also.