Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

replace line break with html line break js

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);
Source by javascriptf1.com #
 
PREVIOUS NEXT
Tagged: #replace #line #break #html #line #break #js
ADD COMMENT
Topic
Name
4+9 =