String Converter: nl2br - Node.js String

Node.js examples for String:HTML String

Description

String Converter: nl2br

Demo Code


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

Related Tutorials