How to use php regular expressions to extract html tags

Source: Internet
Author: User
How to use php regular expressions to extract html tags How to use php regular expressions to extract html tags

    · Shanghai steel market price summary in March 14    March 14        · Price Summary of Beijing steel market in March 14    March 14        · Tianjin Steel market price summary in March 14    March 14        · Chongqing steel market price summary in March 14    March 14        · Price Summary of Guangzhou steel market in March 14

I want to get all×××In the middle of the tag, how should I write a regular expression?

Reply to discussion (solution)
$pattern = "/([\s\S]*)<\/td>/"; preg_match_all($pattern, $str, $matches); var_dump($matches);

The test can pass

$pattern = "/([\s\S]*)<\/td>/"; preg_match_all($pattern, $str, $matches); var_dump($matches);

The test can pass
Change rules

$pattern = "/([\s\S]*?)<\/td>/"preg_match_all("/
 
  (.*)<\/td>/iUs", $str, $output);print_r($output);
 

The above is the question about extracting html tags using php regular expressions. For more information, see PHP Chinese website (www.php1.cn )!

Related articles:

Php code example for extracting html tags

Use php to extract HTML tags

Php regular expression to extract Image URLs

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.