Remove carriage return and space from a string August 28, 2023 by Tarik Try: t.replace(/[\n\r]+/g, ''); Then: t.replace(/\s{2,10}/g, ' '); The 2nd one should get rid of more than 1 space