Remove the HTML tag function removehtmltab (tab) {return tab.replace (/<[^<>]+?>/g, ");//delete all HTML tags}// The normal character is converted to the signifier function Html2escape (sHtml) {return shtml.replace (/[<>& "]/g,function (c) {return {' < ': ' < ', ' > ': ' > ', ' & ': ' & ', ' ' ' ': ' ' '}[c ';} Convert the signifier to normal character function escape2html (str) {var arrentities={' lt ': ' < ', ' GT ': ' > ', ' nbsp ': ', ' amp ': ' & ', ' quot ': ' "' }; Return Str.replace (/& (Lt|gt|nbsp|amp|quot);/ig,function (all,t) {return arrentities[t];}); Turn to space function Nbsp2space (str) {var arrentities = {' nbsp ': '}; return Str.replace (/& (nbsp);/ig, function (al L, t) {return arrentities[t]})}//carriage return to BR label function RETURN2BR (str) {return str.replace (/\r?\n/g, "<br/>");} Remove the opening end wrap and convert more than 3 consecutive lines into 2 newline function trimbr (str) {Str=str.replace (/((\s| ) *\r?\n) {3,}/g, "\r\n\r\n");// Limit up to 2 newline Str=str.replace (/^ ((\s| ) *\r?\n) +/g, ');//clear start line-break Str=str.replace (/((\s| ) *\r?\n) +$/g, ');// Clear end wrap return str;} Combine multiple contiguous spaces into a single space function Mergespace (str) {Str=str.repLace (/(\s| ) +/g, '); return str;}
JS Convert HTML escape character