Re: Regular Expression Problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



At 1/24/2007 02:27 PM, Richard Luckhurst wrote:
What I am trying to do is extract the first <flight ..... /flight> chunk.
...
preg_match('#<flight .*\/flight>#', $xml_string,$matches);
$tempstr = $matches[0];

What I actually get in $tempstr is everything from the first <flight through to
the last (second) </flight>

I would have expected preg_match to have matched from the first <flight through
to the first </flight>.


At 1/24/2007 02:55 PM, Jochem Maas wrote:
<accent voice="pirate">
        you be needing an ungreedy modifier on yer regex.
</accent>

see here:
http://php.net/manual/en/reference.pcre.pattern.modifiers.php


You can also ask regexp to return the text up to but not including the next '<':

        #<flight [^<]+#

'<flight ' followed by one or more characters that aren't '<'.

Regards,

Paul
__________________________

Juniper Webcraft Ltd.
http://juniperwebcraft.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux