Convert new line to <BR> - Node.js String

Node.js examples for String:HTML String

Description

Convert new line to <BR>

Demo Code


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

Related Tutorials