📜  nl2br javascript - 任何代码示例

📅  最后修改于: 2022-03-11 14:55:47.338000             🧑  作者: Mango

代码示例2
function nl2br (str, is_xhtml) {
    if (typeof str === 'undefined' || str === null) {
        return '';
    }
    var breakTag = (is_xhtml || typeof is_xhtml === 'undefined') ? '
' : '
'; return (str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1' + breakTag + '$2'); }