Re: ereg questions

From: Date: Thu, 24 May 2001 14:30:00 +0000
Subject: Re: ereg questions
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-54229@lists.php.net to get a copy of this message
Thanks alot, now i know what are thos \\$NUM but one more thing, where're those \\0 come from? just found it on some scripts using \\0. seems to confuse me a bit. Thanks ----- Original Message ----- From: "Dan Lowe" <dan@tangledhelix.com> To: "Ker Ruben Ramos" <kramz@iligan.mine.nu> Cc: <php-general@lists.php.net> Sent: Thursday, May 24, 2001 5:18 PM Subject: Re: [PHP] ereg questions > Previously, Ker Ruben Ramos said: > > hmm, got a little question. > > 1. what's that \\1 and \\2? got any info on where u got that from? > > Expands to whatever the parentheses surrounded during the match. So > in this case you have: > > Match pattern: "<a href=\"([^/]+)/(.*)\\.html\">" > Replace pattern: "<a href=\"file.php?file=\\1\\2.php\">" > > There are two places in the match pattern where there are (). These are > memorized (rather whatever they actually matched was memorized) and then > you can spit it back out in the replacement pattern using \\1, \\2, etc. > > -dan > > > 2. what if it's just href="anything.html" ? i mean.. something like it got > > lots of subdirectories or not. > > > > Thanks > > ----- Original Message ----- > > From: "Mark Maggelet" <maggelet@mminternet.com> > > To: <kramz@iligan.mine.nu> > > Sent: Thursday, May 24, 2001 1:19 AM > > Subject: Re: [PHP] ereg questions > > > > > > > On Thu, 24 May 2001 01:01:16 +0800, Ker Ruben Ramos > > > (kramz@iligan.mine.nu) wrote: > > > >How do i change all '<a href="anything/here.html">' to > > > >'<a > > > >href="file.php?file=anythinghere.php">' > > > >any help out there? > > > > > > I would go: > > > > > > $string = ereg_replace( > > > "<a href=\"([^/]+)/(.*)\\.html\">", > > > "<a href=\"file.php?file=\\1\\2.php\">", > > > $string); > > > > > > - Mark > > > > > > > > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > > For additional commands, e-mail: php-general-help@lists.php.net > > To contact the list administrators, e-mail: php-list-admin@lists.php.net > > -- > If carpenters made buildings the way programmers make programs, the first > woodpecker to come along would destroy all of civilization. > -Weinberg's Second Law >

« previous php.general (#54229) next »