Skip to content

Instantly share code, notes, and snippets.

@tomoyamkung

tomoyamkung/lf2br.js

Created Nov 18, 2013
Embed
What would you like to do?
[JavaScript]改行コードを <br /> タグに置き換える。
/**
* 改行コードを <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
You can’t perform that action at this time.