skate wrote:

$contents = preg_replace( "|<item>.*?$file.*?</item>|si", "", $contents );

it's being run on an XML file, where each entry is <item>......</item> with
a $file pointer in there.

it works okay, except for the fact that it deletes that record, and every
record before it. i can't figure out why it's being greedy? i know i gotta
be missing something real simple...

What are the possible values of $file? Are you looking to replace just a specific occurance of a $file between <item> tags? Maybe this will help:


$contents = preg_replace("|<item>[^<]*$file[^<]*</item>|si","",$contents);

or just use the 'U' modifier for "ungreedy"...

--
---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

PHP|Architect: A magazine for PHP Professionals – www.phparch.com





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to