let multilineString = `My text 1 2 3 4 is here`; let htmlText = multilineString.replace(/( | | | )/g, '<br>'); console.log('Multiline string: ' + multilineString); console.log('HTML text: ' + htmlText);