Article The text written on the input page can be recorded. Text copied from the word cannot be recorded. It is suspected that the format of the word is incorrect. It seems that I want to use regular expressions to remove it. net cannot be written by yourself. Please help me.
// Clear the redundant Word format and paste it
Function cleanandpaste (HTML ){
// Remove all span tags
Html = html. Replace (/<\/? SPAN [^>] *>/GI ,"");
// Remove class attributes
Html = html. replace (/<(\ W [^>] *) class = ([^ |>] *) ([^>] *)/GI, "<$1 $3 ");
// Remove style attributes
Html = html. replace (/<(\ W [^>] *) style = "([^"] *) "([^>] *)/GI, "<$1 $3 ");
// Remove Lang attributes
Html = html. replace (/<(\ W [^>] *) lang = ([^ |>] *) ([^>] *)/GI, "<$1 $3 ");
// Remove XML elements and declarations
Html = html. Replace (/<\\? \? XML [^>] *>/GI ,"");
// Remove tags with XML namespace declarations: <O: P> </O: P>
Html = html. Replace (/<\/? \ W +: [^>] *>/GI ,"");
// Replace the & nbsp;
Html = html. Replace (/& nbsp ;/,"");
// Transform <p> to <div>
VaR Re = new Regexp ("(<p) ([^>] *> .*?) (<\/P>) "," Gi "); // different because of a IE 5.0 Error
Html = html. Replace (Re, "<Div $2 </div> ");
Alert (HTML );
}