Remove pages in Word format

Source: Internet
Author: User
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 );
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.