Javascript String nl2br()

Description

Javascript String nl2br()

String.prototype.nl2br = function()
{
 return this.replace(/([^>])\n/g, "$1<br />\n");
};

Javascript String nl2br()

/**//from  w w w .j a v  a  2 s .  c  o  m
 * Convert newlines to br tags.
 *
 */
String.prototype.nl2br = function () {
 return this.replace (/\n/g, "<br />");
}

Javascript String nl2br()

String.prototype.nl2br = function(){
    return this.replace(/\n/g, '<br/>');
};

Javascript String nl2br()

String.prototype.nl2br = function(){
 var re = new RegExp("\n", "ig");
 return this.replace(re, "<br />");
};

Javascript String nl2br()

/**//www.ja va 2s  .co m
 * Simple new line (\n) convert to <br /> html tags.
 *
 * @returns {string}
 */
String.prototype.nl2br = function() {
    return this.replace(/\n/g, "<br />");
};

Javascript String nl2br()

/**/*from   w  ww. j a  v  a 2s.c o  m*/
 * Add a 'nl2br' PHP like function to String object prototype.
 *
 * @return {string} The new string.
 */
String.prototype.nl2br = function()
{
    return this.replace(/\n/g, "<br />");
};

Javascript String nl2br()

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

Javascript String nl2br()

String.prototype.nl2br = function() {
 return String(this).replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1<br />$2');
}



PreviousNext

Related