PHP regular expressions

Source: Internet
Author: User
PHP regular expression problem Array
(
[Description] => HTTP/1.1 200 OK
Set-Cookie: JSESSIONID = 40ea513defae87d424eacb79c4e8a1b5; Path =/ipcam
Content-Type: text/xml; charset = UTF-8
Transfer-Encoding: chunked
Date: Thu, 27 Jun 2013 01:08:23 GMT
Server: Apache-Coyote/1.1

C1b





1.0
GBK
UserLogin
244ab25cf7f0258401c2ae0b038ead0a


0
}

This is the original string. I want to extract the xml string. do you want to compress it to write the regular expression? what you write is always empty and cannot be compiled.

The result should be:





1.0
GBK
UserLogin
244ab25cf7f0258401c2ae0b038ead0a





Reply to discussion (solution)

So how did you write it?

So how did you write it?

All the regular expressions I write can only retrieve the data of one row, for example, the data of the first row of xml:
'/\ <\?. *\? \> /'

However, if I cannot retrieve multiple lines of xml data, for example:
'/\ <\? Xml. * Envelope \> /'

$preg='/<\?xml version\="1\.0" encoding\="UTF\-8" \?>(.*?)\}/ius';preg_match_all($preg, $str, $lined);print_r($lined);


Let's look at the rest. remember not to miss the ius, otherwise it will be blank. The latter is case insensitive and multi-row mode matching.


So how did you write it?

All the regular expressions I write can only retrieve the data of one row, for example, the data of the first row of xml:
'/\ <\?. *\? \> /'

However, if I cannot retrieve multiple lines of xml data, for example:
'/\ <\? Xml. * Envelope \> /'

You can also

$preg='/\<\?xml.*Envelope\>/ius';preg_match_all($preg, $str, $lined);print_r($lined);

View results by yourself

The key is that the following ius multi-row matching mode is case insensitive.

The key is that the following ius multi-row matching mode is case insensitive.


Master. Thanks to the moderators.

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.