RE: [PHP] regular expressions gods!

From: Date: Wed, 23 Aug 2000 05:46:36 +0000
Subject: RE: [PHP] regular expressions gods!
Groups: php.general 
Request: Send a blank email to php-general+get-13087@lists.php.net to get a copy of this message
You should be able to exclude / in the reg exp, ie for ($i=0; $i< $(your number of tags-1); $i++) eregi_replace("(href=\")([^\/]*\.php)", "href=\"text_\\2", $tags[$i]); This will ommit matching anything with a / between the " and .php If you're using ./filename.php3 though then this won't work ... > -----Original Message----- > From: Justin French [mailto:justin@indent.com.au] > Sent: Wednesday, 23 August 2000 15:16 > To: WILSON, Nick > Cc: 'jeremy brand'; php-general@lists.php.net > Subject: Re: [PHP] regular expressions gods! > > > "WILSON, Nick" wrote: > > > I think he was only looking to match .php files, so something more > > like > > > > for ($i=0; $i< $(your number of tags-1); $i++) > > eregi_replace("(href=\")(.*\.php)", "href=\"text_\\2", > $tags[$i]); > > > > The \\2 is the second match, ie everything in the second > lot of brackets. > > Not tested. > > > yeah, cool -- almost there!! > > the only other thing is NOT to do the replace if the HREF="" refers to > anything other than a php3 file IN THE SAME DIRECTORY... > > so /mydir/blah.php3 shouldn't be replaced by > /mydir/text_blah.php3 or text/mydir/blah.php3 > > and > http://www.domain.com.au/mydir/blah.php3 shouldn't be replaced with text_http://www.domain.com.au/mydir/blah.php3 Thanks heaps everyone for your help -- almost there !! Justin French

« previous php.general (#13087) next »