javascript replace newline with br
function nl2br(str){
return str.replace(/(?:\r\n|\r|\n)/g, '<br>');
}
var stringWithNewLines= `Well this is a
a very broken
sentance`;
var stringWithBrs=nl2br(stringWithNewLines);
// stringWithBrs= "Well this is a<br>a very <br>broken<br>sentance"
Also in JavaScript:
- jquery form validation
- how to create monorapo project in angular 8
- javascript change image src
- create javascript button
- javascript take last element of array
- discord.js listen for message
- vuejs cant add script in template
- how to install all needed modules in node
- using multiple http verbs on express path request
- package.json beginner
- axios react post form data
- post jquery
- model mongoose
- js alert yes no
- vue js get width of element
- react class component
- javascript audio duration property returns infinity
- base64 encode node js
- javascript pass function as parameter
- python print pretty json
- react conditional class
- how to make a inventory in js
- exceljs read file
- queryselector data attribute