Re: greedy preg
| From: | skate | Date: | Thu, 07 Aug 2003 12:41:42 +0000 |
| Subject: | Re: greedy preg | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-158644@lists.php.net to get a copy of this message | ||
$contents = preg_replace( "|<item>.*?".$file.".*?</item>|si",
"",
$contents );
okay, so i figured out that it's matching the first occurence of <item>
which will always be the first record and then going on to match the $file
and deleting everything between. obviously not what i want.
without giving <item> a unique attribute and without preg_match_all and
looping through them all, is there any other way to do this? make it find
the first occurence of <item> previous to $file, rather than from the start?
i hope this makes sense, and is a little clearer than i've been so far...