[PHP] Re: tricky preg_replace and how to escape the \{occurencenumber}

2002-08-16 Thread B.C. Lance

probably this will be faster?

$fn = str_replace(.gif, 1.gif, $fn);

Lallous wrote:
 ?
 $fn = 'test.gif';
 
 echo preg_replace('/(.+?)(\..+?)/', '\1a\2', $fn);
 
 ?
 
 This script will output 'testa.gif'
 
 now how can i make it produce 'test1.gif' ?
 
 if i replace the: '\1a\2' with '\11\2' it will understand to replace with
 occurence number 11 !
 How can i escape the 2nd '1' so it is considered as a string an not another
 number.
 
 
 Elias
 
 


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




[PHP] Re: tricky preg_replace and how to escape the \{occurencenumber}

2002-08-16 Thread lallous

Oh well,

I could have solved it w/ too many other methods, but how can I escape the
\{occurence} as in my case?

Elias

B.C. Lance [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 and if you are gonna append '1' for all extension,

 try this:
 echo preg_replace('/(\..+?)/', '1$1', $fn);

 Lallous wrote:
  ?
  $fn = 'test.gif';
 
  echo preg_replace('/(.+?)(\..+?)/', '\1a\2', $fn);
 
  ?
 
  This script will output 'testa.gif'
 
  now how can i make it produce 'test1.gif' ?
 
  if i replace the: '\1a\2' with '\11\2' it will understand to replace
with
  occurence number 11 !
  How can i escape the 2nd '1' so it is considered as a string an not
another
  number.
 
 
  Elias
 
 




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




[PHP] Re: tricky preg_replace and how to escape the \{occurencenumber}

2002-08-16 Thread B.C. Lance

hm...

this should work, notice the double quotes

echo preg_replace('/(.+?)(\..+?)/e', '\1.1.\2', $fn);

Lallous wrote:
 Oh well,
 
 I could have solved it w/ too many other methods, but how can I escape the
 \{occurence} as in my case?
 


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