How does ueditor extract the string of the <p> tag? Or use php to extract strings.

Source: Internet
Author: User
How to extract a fixed number of characters from the content of the & amp; lt; p & amp; gt; tag as a post introduction? I think Baidu Post Bar extracts a certain number of characters from the front of a post and displays them as an introduction to the post. Assume that the following is a content example: & amp; lt; p & amp; gt; somecontent... & amp; lt; p & amp; gt ;...

What is the description of a post by extracting a fixed number of characters from the TAG content? I think Baidu Post Bar extracts a certain number of characters from the front of a post and displays them as an introduction to the post. For example,

some content...

...
...

...

...

Because one

The content length in the tag is not fixed, and it may start with an image.Tag, or insert Code

Tags, and so on.

The tag can be extracted with 50 characters. If not, can php be used efficiently?

Reply content:

How

What is the description of a post by extracting a fixed number of characters from the TAG content? I think Baidu Post Bar extracts a certain number of characters from the front of a post and displays them as an introduction to the post. For example,

some content...

...
...

...

...

Because one

The content length in the tag is not fixed, and it may start with an image.Tag, or insert Code

Tags, and so on.

The tag can be extracted with 50 characters. If not, can php be used efficiently?

Hello, I feel that I can use regular expressions to match the content and extract the content using preg. If this is not the case, I can use js traversal. I hope you can try again. If not, please confirm.

Regular Expression + String Truncation

] +> (.*?)


Simple regular expressions.

Assume that you have found

Tag, which can be created using substr + strip_tags

How to find

Label. You can use regular expressions or PHPQuery.

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.