Re: regular expressions gods!
| From: | Justin French | Date: | Wed, 23 Aug 2000 05:15:44 +0000 |
| Subject: | Re: regular expressions gods! | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-13082@lists.php.net to get a copy of this message | ||
"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