trim nodejs sentence from spaces code example Example: trim nodejs sentence from spaces newString = string.replace(/\s+/g,''); // "thiscontainsspaces"