Re: Regular Expression Problem
| From: | Paul Novitski | Date: | Wed, 24 Jan 2007 23:37:33 +0000 |
| Subject: | Re: Regular Expression Problem | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-247734@lists.php.net to get a copy of this message | ||
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 can also ask regexp to return the text up to but not including the next '<':you be needing an ungreedy modifier on yer regex.</accent> see here: http://php.net/manual/en/reference.pcre.pattern.modifiers.php
#<flight [^<]+#'<flight ' followed by one or more characters that aren't '<'. Regards, Paul __________________________ Juniper Webcraft Ltd. http://juniperwebcraft.com