How to get plain text for some filters in rich text?

Source: Internet
Author: User
For example, a long article with HTML tags to get 400 characters of text, filter content conditions are, only left: 超链接, label , Bold label , Italic label .
The remaining labels leave only plain text.
Remove line breaks and IMG tags. See more than two spaces replaced by a single space.
within 400 characters if , bold, italic labels are not closed to filter the rest of the contents of the closing tag.
400 characters If the hyperlink is not closed until the end of the hyperlink closes.
There are many examples on the web that do not fit. So I asked the question on SF. You do not want to delete the problem. The ability of the programmer to give help.

reply content:

For example a long article with HTML tags get 400 characters of text, filter content condition is, only left: hyperlink , label , Bold Label , Italic label .
The remaining labels leave only plain text.
Remove line breaks and IMG tags. See more than two spaces replaced by a single space.
within 400 characters if , bold, italic labels are not closed to filter the rest of the contents of the closing tag.
400 characters If the hyperlink is not closed until the end of the hyperlink closes.
There are many examples on the web that do not fit. So I asked the question on SF. You do not want to delete the problem. The ability of the programmer to give help.

Visually to write the regular match is replaced according to the condition, respectively. The
recommends looking through a regular tutorial and then splitting the requirements into multiple steps, conquer.

Update:

The need to solve the main problem in addition to string processing, in fact, can also be understood as the processing of the DOM, using JS to handle the DOM is more appropriate.

Previously used simple_html_dom This library, you can manipulate HTML like jquery, I hope it will be useful to you

  • 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.