📜  使用 JavaScript 代码示例删除换行符

📅  最后修改于: 2022-03-11 15:03:08.577000             🧑  作者: Mango

代码示例3
let multilineString = `My
text\r1\r\n2\n3\n\r4
is
here`;

let htmlText = multilineString.replace(/(\r\n|\n\r|\r|\n)/g, '
'); console.log('Multiline string: ' + multilineString); console.log('HTML text: ' + htmlText);