Javascript String nl2br(str, is_xhtml)

Description

Javascript String nl2br(str, is_xhtml)

String.prototype.nl2br = function(str, is_xhtml) {
    var breakTag = (is_xhtml || typeof is_xhtml === 'undefined') ? '<br ' + '/>' : '<br>';
    return (str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1' + breakTag + '$2');
};



PreviousNext

Related