Skip to content

Instantly share code, notes, and snippets.

@jdforsythe
Created July 31, 2015 11:36
Show Gist options
  • Save jdforsythe/82d2d7b0eb9e55dbf6f7 to your computer and use it in GitHub Desktop.
Save jdforsythe/82d2d7b0eb9e55dbf6f7 to your computer and use it in GitHub Desktop.
Javascript - replace line breaks in string with br tags
// 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