Regex Lepaskan beberapa ruang
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, ' ');