Regex entfernen mehrere Räume
string = string.replace(/\s\s+/g, ' ');
Distinct Deer
string = string.replace(/\s\s+/g, ' ');
//..
return str.replace(/\s/g, '');
//..
\s* ignore spaces
eg \s*yourregex\s*
string = string.replace(/ +/g, ' ');