showing results for - "javascript replace line breaks with br"
Lilia
03 Oct 2019
1function nl2br(str){
2 return str.replace(/(?:\r\n|\r|\n)/g, '<br>');
3}
4var stringWithNewLines= `Well this is a
5a very broken
6sentance`;
7var stringWithBrs=nl2br(stringWithNewLines);
8// stringWithBrs= "Well this is a<br>a very <br>broken<br>sentance"
Carsten
01 Jul 2019
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);
queries leading to this page
javascript replace 5cn with brreplace character with newline javascripthow to remove newlines in a string javascriptjavascript replace string new linephp replace spacesreplace 5cn javascriptreplace 5cn in text jsjs replace line breaksjquery remove line breaks from htmljavascript replace br tag with newlinereplace newline jshow to replace new line in jsjavascript replace br to newline replace 28 2f 28 5cr 5cn 7c 5cn 7c 5cr 29 2fgm 2c 22 2c 22 29 3bhow to remove a line break in nodejsjavascript replace line breaks with 5cnjs loop on text to add line breakconvert text with 0d 0a to html javascripthow to add vertical lines in htmljavascript replace newline with brhow to add a line break in jsjavascript replace new line in stringhow to handle linebreak in javascriptreplace all linebreaks with 3cbr 3e jsjs replace br with new linejavscript replace by newlinejava srcip remvoe new line end textreplace br javascriptjs replace line breaks with brjs replace string new line to stringhow to replace newline javascriptjavascript how to add line breakjavascript replace character with line breakjavascript replace 3cbr 2f 3ejavascript replace new line with 5cnstring replace line break javascriptjavascript replace newlinereplace new line textarea in javascriptadd line break to word in javascriptjavascript replace new linesjs replace 2c with line breakreplace 5cn in jsreplace space with line break javascriptreplace 5cn with new string javascriptreplace br with newline javascriptjavascript replace brjavascript replace line breakjavascript replace enwline character with newlinereplace 5cn with br jshow to get rid of a new line from a string in jsjavascript replace new linejavascript replace 2c with line breakreplace n with br javascriptreplace new line character with 22 5cn 22 in javascriptjs replace new line brhow to replace or new line or br in text in javascriptjavascript add breakline in textjavascript replace br realreplace string with br tag in javascripthow to replace 5cn with 5c 5cn in javascriptjavascript string replace new line characterjavascript replace line breaks with brjavascript replace 5cnjs replace 5cr 5cnpreserve line break in a string javascripthow insert html line break inside js stringreplace line break javascriptjs br replace 5cnjavascript string replace newlinejavascript replace newline with spacereplace endline in string jsjs replace 5cn with 3cbr 3ejs replace 3cbr 2f 3ejavascript replace with string with newlinejavascript replace br tag with new linejs replace br with enterreplace new line javascriptclear line space nodejsjs replace n with brremove newline from end of string javascripthow to replace new line jstext replace 5cn javascriptjavascript replace all line breaks with brreplace n by new line jsjavascript string replace new line with brreplace new lines javascriptreplace javascript 5cnnew line using in the replace method in javascript stringreplace newline with br javascriptjavascript replace line breaks with spacejavascript replace 5cnreplace br to newline in javascripthow to replace br with newline in javascriptreplace with new line in javascriptreplace 5cn 5ct from string in javascriptjavascript replace all character br with r new linereplace new lines with 5cn in jsreplace 5cn from string jsreplace line breaks javascriptreplace n in jsjavascript carriage return and new line character replacejavascript line breakjs replace newline javascript trim line breakshow to make a line break at some amount of words in javascripthow to replace 5cn from string jsjs string replace newlinereplace n to br javascriptreplace space with new line jsreplace new line character in javascriptforce line break in javascriptline break in string javascripthow to put line break in jsjs replace with line breakreplace br tag with newline javascriptjavascript how to replace br tag with 5cnhow to add a line break in a string jsreplace line breaks in string javascriptnew line string remove javascriptjs replace 5cn with br tagadd line break in javascriptjavascript replace string with newlinejavascript replace line breaksjs replace new lines with 22 22js replace new linesjquery remove newline from stringbreak line javascriptjs n replace brjs replace new line with line endreplace 2fn with newline jsremove trailing line breaks using javascriptreplace 5cn with actual new lines javscripthow to break a line in javascriptjavascript string replace with newlinesjavascript replace 5cr 5cnreplace br with n in javascriptstring replace newline javascriptjs replace newline characterreplace new line with br jsjavascript replace in all linesconvert 5cr 5cn 5cr 5cn to a new line jshow to remove extra br using replace in javascriptgive line break in javascriptforce line break in a string javascript that goes to htmljavascript remove all 5cnstr replace line break jaascriptjs replace newline with p elementjavascript replace new line with brreplace 3cbr 3e with 5cn javascriptreplace the newline with jswhen to add line break in jsreplace breaklines jsreplace with line break in javascriptbreak line new line html javascriptjavascript regex replace new line with brstring replace new line javascriptreplace breaklines from string jsjavascript replace enter to newlinesreplace string with newline javscriptjs manipulate tag to break linereplace with newline javascriptjavascript 5cn not creating new line brreplace n in javascriptphp remove line breakhow to replace br to new line in javascriptjavascript replace r n with newlinereplace break line javascriptremove leading br in javascripthow to replace br with next line in javascriptjavascript replace all new linereplace line break with br javascriptreplace new line in string javascriptchange line in jsjs replace 3cbr 3e to 5cnjavascript replace with new linejavascript replace br in stringreplace character in a string with newline javascriptreplace line break with html line break jsjs insert line break in stringjavascript replace 2fn with brjavascript replace newline with paragraphget rid of any line endings javascriptstr replace newline javascriptjs code delete linereplace newlines jsjs insert break where line wrapsjavascript replace line break with brremove line breaksremove line breaks in word javascripthow to replace linebreak in javascriptjavascript replace new line characterreplace 2fn with line breaks jsjavascript replace line breaks with nreplace newline with space javascriptreplace newline javascriptjs replace 5cn with brhow to replace line breaks in javascriptjavawascript string replace new line from textjavascript replace string with new linejavascript replace r n with brhow to make line break in javascriptjs replace new line with brstring replace with new line jsline break js stringreplace newline by 5cn in text jsreplace n in string javascriptreplace 5cn jsreplace newlines with br javascriptjavascript replace enter to bradd line break in js replace break lines javascriptreplace line break jsjavascript replace 5cn with real new linejs replace line break wit hnothingjavascript replace n to brjs replace break linesjs replace newline with spacereplace breakline javascriptjavascript replace line return with 5cnreplace new line with space javascriptjs replace n with newlinereplace something with new line in jsreplace java new line with br javascripthow to force new line in string javascriptreplace the enter symbol with new line javascriptjs replace break linejavascript replace 5cr 5cn 5ctjavascript replace with 3cbr 3eunix 2b remove blank lines from a filejavascript replace with brjs string replace new lineremove line breaks with javascriptjs replace new linereplace line break with n in javascriptchange br with 5cn jshtml dom line break replace n with break javascriptreplace r n in javascriptconvert text with 5cr 5cn to html javascriptjavascript replace 5cn with new linejs text replace 3cbr 3ejavascript replace newline character with newlineline break jsreplace line breaks with 5cn jshow to replace 5c 5cn with 5cn in a string javascripthow to replace new line character in javascriptjs replace n to brhow to break the line in javascriptreplace string with new line in javascriptreplace r n with br javascriptjavascript string replace insert line breakadd line break html with jsjavascript convert newline to brhow to replace n with new line in javascriptjavascript replace space with line breaknodejs replace 5cn with newlinejs replace 5cnreplace n with newline javascriptjavascript readlinejs replace 5cn with line breaksreplace 5cr 5cn 2f with br javascripthow to replace a character with a line break jsjavascript replace character with newlinejavascript replace n with brjavascript replace line breaks with br