//Remove HTML Tagsfunctionremovehtmltab (tab) {returnTab.replace (/<[^<>]+?>/g, ");//Delete all HTML tags}//convert ordinary characters to a signifierfunctionHtml2escape (sHtml) {returnShtml.replace (/[<>& "]/g,function(c) {return{' < ': ' < ', ' > ': ' > ', ' & ': ' & ', ' ' ': ' " '}[c];});}//Convert the signifier to ordinary charactersfunctionescape2html (str) {vararrentities={' lt ': ' < ', ' GT ': ' > ', ' nbsp ': ', ' amp ': ' & ', ' quot ': ' "'}; returnStr.replace (/& (Lt|gt|nbsp|amp|quot);/ig,function(all,t) {returnarrentities[t];});}// turn into spacesfunctionNbsp2space (str) {varArrentities = {' nbsp ': '}; returnStr.replace (/& (nbsp);/ig,function(All, T) {returnarrentities[t]})}//return to BR labelfunctionreturn2br (str) {returnStr.replace (/\r?\n/g, "<br/>");}//Remove the opening end wrap and convert more than 3 consecutive lines to 2 line breaksfunctiontrimbr (str) {str=str.replace (/((\s| ) *\r?\n) {3,}/g, "\r\n\r\n");//limit up to 2 line breaksStr=str.replace (/^ ((\s| ) *\r?\n) +/g, ');//Clear start line breakStr=str.replace (/((\s| ) *\r?\n) +$/g, ');//Clear End Line wrapping returnstr;}//combine multiple contiguous spaces into a single spacefunctionMergespace (str) {str=str.replace (/(\s| ) +/g, "); returnstr;}
JS Convert HTML escape character