I'm trying to replace all relative links in a string like:

str$="<a href="jan_may2000/files.html">" to

str$="<a href="http://myhost.com/jan_may2000/files.html";>"

I don't want to change any links that begining with http or mailto links.

my code is:

<?
// change all relative links to include base url
$url = "news/";
$fnd = "a href=\"[^http)(mailto)#]";
$str_new = ereg_replace($fnd, "a href=\"" . $url . "", $str_old);
$news_body = $str_new;
?>

$str_old has the complete html body of the page (all content between <BODY>
tags), so none of the other html must be touched

It works, EXCEPT that $str_new returns what I want but strips the first
character after href.   Using the example given above:

IF str$="<a href="jan_may2000/files.html">"    after using the ereg function
it becomes :

str$="<a href="http://myhost.com/an_may2000/files.html";>"
                                                  ^^  notice the missing
character.

What I'm doing wrong?






-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to