Today in the Wangeditor editor to write the background Management article page, after saving the article need to call an edit draft, this time need to put the content of the editor to the editor, the results output my label:<p> Hello </p> after my Console.log ( data) = = "<p> Punching sandbags </p> "。 Yes, my <> is escaped, because there is no way to upload a word without escaping it.
And then there's the regular I'm looking for from somewhere else. Ha haha ~
Remove the HTML tag function removehtmltab (tab) {return tab.replace (/<[^<>]+?>/g, ");//delete all HTML tags}
Normal character converted to Html2escape function (sHtml) {return shtml.replace (/[<>& "]/g,function (c) {return {' < ': ' < ', ' > ': ' > ', ' & ': ' & ', ' ' ' ': ' ' '}[c ';}
I am using the following, just fine. hehe ~
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 into a space function nbsp2space (str) {var arrentities = {' nbsp ': '}; return Str.replace (/& (nbsp);/ig, function (all, t) {return arrentities[t]})}
Carriage return to BR label function RETURN2BR (str) {return str.replace (/\r?\n/g, "<br/>");}
Removes the opening end wrap and converts 3 or more 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 newline str=str.replace (/((\s|) *\r?\n) +$/g, ');//clear end newline 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