Re: greedy preg
| From: | Marek Kilimajer | Date: | Thu, 07 Aug 2003 12:58:08 +0000 |
| Subject: | Re: greedy preg | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-158645@lists.php.net to get a copy of this message | ||
Do you need to use ".*?"? If there will be only white characters, use \s* instead.
skate wrote:
$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...