Search
 
SCRIPT & CODE EXAMPLE
 

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);
Comment

PREVIOUS NEXT
Code Example
Javascript :: detect emoji in string javascript 
Javascript :: altv rpc 
Javascript :: check if an object contains a value in javascript 
Javascript :: latitude and longitude distance calculate in node js 
Javascript :: month list javascript 
Javascript :: material ui textfield change input color 
Javascript :: toaster cdn 
Javascript :: rename file in js 
Javascript :: javascript append item to array 
Javascript :: nodejs fetch 
Javascript :: queryselector a tag with text 
Javascript :: Install react router in react app 
Javascript :: loop through files in directory javascript 
Javascript :: redux template create react app 
Javascript :: Reverse pyramid star pattern in JavaScript 
Javascript :: call javascript function after page load complete 
Javascript :: two digit js' 
Javascript :: javascript video feed 
Javascript :: js first letter to uppercase 
Javascript :: js add more text to element 
Javascript :: javascript pushstate 
Javascript :: gulp run sequence 
Javascript :: javascript function argument type 
Javascript :: width and height in js 
Javascript :: get keys of object in an array 
Javascript :: mil to km javascript 
Javascript :: js escape html 
Javascript :: random word js 
Javascript :: js pow 
Javascript :: how to get data from url in vuejs 
ADD CONTENT
Topic
Content
Source link
Name
3+8 =