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

From: Date: Fri, 16 Aug 2002 14:13:12 +0000
Subject: Re: tricky preg_replace and how to escape the \{occurencenumber}
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-112956@lists.php.net to get a copy of this message
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" <lornie@magix.com.sg> wrote in message news:3D5CE1B9.1020103@magix.com.sg... > 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 > > > > >

« previous php.general (#112956) next »