PHP Regular expression matching <p style= "xxxx" ><span style= "xxxx" >html content </span></p>

Source: Internet
Author: User
Tags php regular expression
Web content has recently been crawled, but regular expressions are not familiar and difficult to write.
Now we need to match this.

Label

Which great God can give a regular expression, when practicing practiced hand ha, grateful!

Reply content:

Web content has recently been crawled, but regular expressions are not familiar and difficult to write.
Now we need to match this.

Label

Which great God can give a regular expression, when practicing practiced hand ha, grateful!

Although I am not phper, but also through a variety of ways to do HTML parsing.
We can use regular, DOM, Xpath, CSS query to solve the problem of the main question.
The regular will change with more difficult to understand,
Although the DOM is more readable, it is cumbersome,
XPath brings up the problem with HTML clean,
I strongly recommend it in a css query way.

The main problem is to try the class library:
http://simplehtmldom.sourceforge.net/
https://code.google.com/p/phpquery/

http://txt2re.com solve your headache problem ... RegExp Generator (I won't use it anyway)
Wrote a

$regexp=/

.*

/g;

I did not test under PHP ... And the temporary writing is also more bloated

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