Re: [PHP] greedy preg

2003-08-14 Thread CPT John W. Holmes
From: skate [EMAIL PROTECTED] $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

Re: [PHP] greedy preg

2003-08-14 Thread John W. Holmes
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

Re: [PHP] greedy preg

2003-08-14 Thread skate
$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

Re: [PHP] greedy preg

2003-08-14 Thread SLanger
preg_replace(|item.*?$file.*?/item|si,,$contents) news item titlefhh/title date1060205191/date texthhh/text filexml/news/1060205191.xml/file /item item titlefgjghjh/title date1060205186/date textfgjh/text filexml/news/1060205186.xml/file /item item

Re: [PHP] greedy preg

2003-08-14 Thread skate
Not sure if I understand you correct but the way you wrote your replace pattern the result should be news/news. If you want just the file to be replaced you have to use something like preg_replace(|item.*?($file).*?/item|si,'\\1',$contents) no, i want just the whole item/item replaced for

Re: [PHP] greedy preg

2003-08-14 Thread skate
And what about [^]* -if there are no html tags not thought about that, but XML tags, not HTML tags... does that make any difference? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] greedy preg

2003-08-14 Thread Kevin Stone
- Original Message - From: skate [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, August 06, 2003 3:16 PM Subject: [PHP] greedy preg $contents = preg_replace( |item.*?$file.*?/item|si, , $contents ); it's being run on an XML file, where each entry is item../item with

Re: [PHP] greedy preg

2003-08-14 Thread skate
Do you need to use .*?? If there will be only white characters, use \s* instead. unfortunately there's some content either side of $file before item/item this content is different for each item, so i can't define it in the pattern. -- PHP General Mailing List (http://www.php.net/) To

Re: [PHP] greedy preg

2003-08-12 Thread Marek Kilimajer
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

Re: [PHP] greedy preg

2003-08-11 Thread skate
You cannot store file pointers. If you output the variable it's going to look something like Resource ID #1 which is meaningless except to the instance of the script that created it. Or did you mean something different by $file pointer? sorry, wrong words... when i meant $file is equal

Re: [PHP] greedy preg

2003-08-07 Thread John W. Holmes
skate wrote: 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... i'm looking to replace the

Re: [PHP] greedy preg

2003-08-07 Thread Marek Kilimajer
And what about [^]* -if there are no html tags skate wrote: Do you need to use .*?? If there will be only white characters, use \s* instead. unfortunately there's some content either side of $file before item/item this content is different for each item, so i can't define it in the pattern.

Re: [PHP] greedy preg

2003-08-06 Thread skate
Yeah, it should be. What kind on content can be around $file and also within the item tag? here's a snip of the xml file... it's finding the $file correctly, but deletes all records from the beginning of the file onwards. it leaves the xml file with valid xml ... news at the start... so for

Re: [PHP] greedy preg

2003-08-06 Thread skate
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... i'm looking to replace the entire