1var stringWithLineBreaks = `
2O boy
3I've got
4Breaks
5`;
6var stringWithoutLineBreaks = stringWithLineBreaks.replace(/(\r\n|\n|\r)/gm, "");//remove those line breaks
1let multilineString = `My
2text\r1\r\n2\n3\n\r4
3is
4here`;
5
6let htmlText = multilineString.replace(/(\r\n|\n\r|\r|\n)/g, '<br>');
7
8console.log('Multiline string: ' + multilineString);
9console.log('HTML text: ' + htmlText);