An error occurred while reading a regular expression on the webpage. Let's take a look at the error. I 'd better explain the meaning of each symbol. I'm learning. how can I solve it?

Source: Internet
Author: User
An error occurred while reading a regular expression on the webpage. Let's take a look at the error. It is best to explain the meaning of each symbol. I am learning an example of a regular expression on the webpage, and an error has occurred. Let's take a look at the error. It is best to explain the meaning of each symbol. the div tag is being extracted and the content with the ID of PostContent is stored in the array match. Preg_match ('/& lt refers to an example of a regular expression on the webpage, and an error occurs. Let's take a look at the error. It is best to explain the meaning of each symbol.
An error occurred while reading a regular expression on the webpage. Let's take a look at the error. It is best to explain the meaning of each symbol.

// Retrieve the div tag and the content with the ID of PostContent coexist in the array match.

Preg_match ('/] * id = "PostContent" [^>] *> (.*?) /Si', $ text, $ match );

Is this regular expression perl-style. It is not in the POSIX style. The two learning methods are messy.
I want to understand this.

Error message:
Warning: preg_match () [function. preg-match]: Unknown modifier '/' in D: \ xampp \ htdocs \ testweb02 \ t1.php on line 6

------ Solution --------------------
Preg_match ('/] * id = "PostContent" [^>] *> (.*?) /Si', $ text, $ match );
Change
Preg_match ('/] * id = "PostContent" [^>] *> (.*?) <\/Div>/Si', $ text, $ match );
Or
Preg_match ('/] * id = "PostContent" [^>] *> (.*?) <\/Div>/Si', $ text, $ match );
------ Solution --------------------
I am also a regular expression that I just learned. I don't know how to use it. I don't know if it's what you want.
You can use eregi ("
    (.*)
", $ Content, $ eg );
$ Content = file_get_contents ($ url); $ url is the url of the content website you want to intercept, and $ eg stores the content you want to save.
Then echo $ eg [1]; can retrieve the content. as for $ eg, it is an array and I am not very clear about what it is, you can take a look at the knowledge of eregi functions.

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.