ASP replaces tags in word with regular expressions and converts them to plain text

Source: Internet
Author: User

When you use the website background to edit and add the modified content, Company customers often copy the content directly from the word document to the editor and then submit it. The result is a variety of styles on the content display page, and sometimes some plain text content is used as an excerpt, all of which need to clear the Word format. To change the customer's habits, it is difficult for the customer to copy it to the notepad and paste it into the editor for editing. Therefore, we should change it ourselves. Baidu has cleared several regular expressions in the Word format from the Internet, which is not very effective. Therefore, I wrote ASP functions to clear the Word format, which can meet our own needs. The function is as follows: CopyCodeThe Code is as follows: function cleanword (HTML)
Dim RegEx
Set RegEx = new Regexp
RegEx. ignorecase = true
RegEx. Global = true
RegEx. pattern = "<[^>] *>" 'clear content between all <>
Html = RegEx. Replace (HTML ,"")
RegEx. pattern = "{[^}] *}" 'clears content between all {}
Html = RegEx. Replace (HTML ,"")
RegEx. pattern = "/[^/] */" 'clear comments between all /**/
Html = RegEx. Replace (HTML ,"")
Html = Replace (HTML, "table. msonormaltable ", "")'
Cleanword = html
Set RegEx = nothing
End Function
Related Article

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.