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 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 unsubsc

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 skate
> Not sure if I understand you correct but > the way you wrote your replace pattern the result should be > . > If you want just the file to be replaced you have to use something like > preg_replace("|.*?($file).*?|si",'\\1',$contents) > no, i want just the whole replaced for that particular file

Re: [PHP] greedy preg

2003-08-14 Thread skate
$contents = preg_replace( "|.*?".$file.".*?|si", "", $contents ); okay, so i figured out that it's matching the first occurence of 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 a unique attri

Re: [PHP] greedy preg

2003-08-14 Thread John W. Holmes
skate wrote: $contents = preg_replace( "|.*?$file.*?|si", "", $contents ); it's being run on an XML file, where each entry is .. 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 greed

Re: [PHP] greedy preg

2003-08-14 Thread SLanger
> preg_replace("|.*?$file.*?|si","",$contents) > > > fhh > 1060205191 > hhh > xml/news/1060205191.xml > > > fgjghjh > 1060205186 > fgjh > xml/news/1060205186.xml > > > fgjhh > 1060205182 > fghh > xml/news/1060205182.xml > > Not sure if I understand you correct

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( "|.*?$file.*?|si", "", $contents ); > > it's be

Re: [PHP] greedy preg

2003-08-14 Thread CPT John W. Holmes
From: "skate" <[EMAIL PROTECTED]> > $contents = preg_replace( "|.*?".$file.".*?|si", "", > $contents ); > > okay, so i figured out that it's matching the first occurence of > 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-11 Thread Marek Kilimajer
Do you need to use ".*?"? If there will be only white characters, use \s* instead. skate wrote: $contents = preg_replace( "|.*?".$file.".*?|si", "", $contents ); okay, so i figured out that it's matching the first occurence of which will always be the first record and then going on to match the

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

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 this content is different for each item, so i can't define it in the pattern. -- P

[PHP] greedy preg

2003-08-07 Thread skate
$contents = preg_replace( "|.*?$file.*?|si", "", $contents ); it's being run on an XML file, where each entry is .. 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

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 tags? Maybe this will help: $contents = preg_replace("|[^<]*$file[^<]*|si","",$contents); or just use the 'U' modifier for "ungreedy"... i'm looking to replace the entir

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 tags? Maybe this will help: > > $contents = preg_replace("|[^<]*$file[^<]*|si","",$contents); > > or just use the 'U' modifier for "ungreedy"... > i'm looking to replace the entire

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 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 ... at the start... so for the