JavaScript to convert HTML Escape characters, jshtml escape characters
// Remove the html Tag
Function removeHtmlTab (tab) {return tab. replace (/<[^ <>] +?> /G, ''); // delete all HTML tags}
// Convert normal characters to escape characters
function html2Escape(sHtml) { return sHtml.replace(/[<>&"]/g,function(c){return {'<':'<','>':'>','&':'&','"':'"'}[c];}); }
// Replace the Italian character with a 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];}); }
// Convert it to a space
function nbsp2Space(str) { var arrEntities = {'nbsp' : ' '}; return str.replace(/&(nbsp);/ig, function(all, t){return arrEntities[t]}) }
// Press enter to convert to a br tag
function return2Br(str) { return str.replace(/\r?\n/g,"<br />"); }
// Remove the start and end line breaks and convert them into two line breaks three times in a row
Function trimBr (str) {str = str. replace (/(\ s |) * \ r? \ N) {3,}/g, "\ r \ n"); // limit up to 2 line breaks str = str. replace (/^ (\ s |) * \ r? \ N) +/g, ''); // clear str = str. replace (/(\ s |) * \ r? \ N) + $/g, ''); // clear the end line feed return str ;}
// Combine multiple consecutive spaces into one space
function mergeSpace(str) { str=str.replace(/(\s| )+/g,' '); return str; }
The above JS conversion of HTML Escape characters is a small part of the Content shared to everyone, I hope to give you a reference, but also hope you can support a lot of help homes.