Created
November 18, 2013 04:22
-
-
Save tomoyamkung/7522439 to your computer and use it in GitHub Desktop.
[JavaScript]改行コードを <br /> タグに置き換える。
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
/** | |
* 改行コードを <br /> タグに置き換える。 | |
* | |
* @param {String} str 改行コードを含んだ文字列 | |
* @returns {String} 置き換えた文字列 | |
*/ | |
function lf2br(str) { | |
return str.replace(/\r?\n/g, "<br />"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment