Ask how to match the regular expression.

Source: Internet
Author: User
How can I match the regular expression? The purpose is to match href in the source code of a webpage. There are three possible types: & lt; thclass = & quot; new & quot; & gt; & nbsp; --- line feed --- & nbsp; --- line feed --- & lt; ahref = & quot; how does the http://bbs.111.com/threa match with regular expressions?
The purpose is to match href in the source code of the webpage. There are three types:
Type 1:

--- Line feed ---
--- Line feed ---
1111 (seo)
Type 2:

[Introduction to spider]Onclick = "atarget (this)" class = "xst"> 2222
Type 3:


3, 3, 3

Write $ pattern = "/". preg_quote ('', '/')." (. *) "." \ n "." ". preg_quote ('
','/'). ". +". Preg_quote ('class = "xst">', '/'). '/I ';
But it cannot be completely matched .. Please help

Let me talk about my ideas first:
Start with or, followed by extra characters, line feed (0 or more), and then end .. However, when matching, it is often not only the content of href, but also the content of other


------ Solution --------------------
PHP code
$ Str = <

  
   
1111 (seo) Type 2:

   [Introduction to spider]2222 Type 3: Three html; preg_match_all ('/(? :). +

  

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.