Javascript String br2nl()

Description

Javascript String br2nl()


String.prototype.br2nl = function()
{
 return this.replace(/<br\s*\/?>/mg, "\n");
};

Javascript String br2nl()

/**/*from   w w  w  .java2s .c  om*/
 * Convert br tags to newlines.
 *
 */
String.prototype.br2nl = function () {
 return this.replace (/\<br ?\/?\>/g, "\n");
}

Javascript String br2nl()

/**//from  ww  w  .  j  a va2s  .c  om
@Name: String.prototype.br2nl
@Author: Paul Visco
@Version: 1.0 11/19/07
@Description: Converts HTML line breaks "<br />" to new lines "\n"
@Return: String The original string but replaces breaks with actual new lines
@Example:
var myString = 'hello<br />there';
var newString = myString.br2nl();
//newString = "hello\nthere";
*/
String.prototype.br2nl = function(){
 var re = new RegExp("<[br /|br]>", "ig");
 return this.replace(re, "\n");
};



PreviousNext

Related