Re: ereg questions

From: Date: Thu, 24 May 2001 09:18:10 +0000
Subject: Re: ereg questions
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-54189@lists.php.net to get a copy of this message
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 (#54189) next »