how to replace all kinds of space with single whitespaces code example Example: replace multiple spaces with single space javascript string = string.replace(/\s\s+/g, ' ');