Created
July 31, 2015 11:36
-
-
Save jdforsythe/82d2d7b0eb9e55dbf6f7 to your computer and use it in GitHub Desktop.
Javascript - replace line breaks in string with br tags
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// see http://stackoverflow.com/a/784547 | |
function replaceLineBreaks(str) { | |
return str.replace(/(?:\r\n|\r|\n)/g, '<br>'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment