Re: preg_replace Problem

From: Date: Mon, 30 Oct 2000 06:17:17 +0000
Subject: Re: preg_replace Problem
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-22615@lists.php.net to get a copy of this message
Yeah I figured that part out eventually. I also needed to use \\2 instead of \\1. It now works as long as I don't put the (^http://) in there, but I need that part so that it doesn't modify urls that are already absolute. Here's my updated script: $article = preg_replace("src=\"(^http://)(.*?)\"i","src=\"http://www.blah.com/\\2\"", $article); Thanks for the help Anarchos ----- Original Message ----- From: "Ben Wiechman" <neteru@aminal.net> To: "Anarchos" <anarchos@apushardware.com> Sent: Monday, October 30, 2000 12:01 AM Subject: RE: [PHP] preg_replace Problem > store the results into a variable... > > $new_url = preg_replace(***blah***); > > Ben > > -----Original Message----- > From: Anarchos [mailto:anarchos@apushardware.com] > Sent: Sunday, October 29, 2000 1753 Neteru > To: php-general@lists.php.net > Subject: [PHP] preg_replace Problem > > > preg_replace("src=\"?(^http://)(.*)\"?iU","src=\"http://www.blah.com/\\1\" > ",$var); > > is the regex that I'm using for an "email this article" script. It is > supposed to take all relative image src's, ie <img src="images/blah.gif", > and append "http://www.blah.com/" to them, so that in > the replacement it > will be: <img src="Ÿ©„x@‘¢ > š‚õê|ýhttp://www.blah.com/images/blah.gif". It is also supposed > to work when the image src is src=imageSrc, or src="imageSrc". But it > doesn't do anything =(. Any ideas? > > Thanks, > Anarchos >

« previous php.general (#22615) next »