php正则表达式替换html中的超链接为绝对地址
$html = preg_replace("#(<\s*a\s+[^>]*href\s*=\s*[\"'])(?!http)([^\"'>]+)([\"'>]+)#", '$1http://mydomain.com/$2$3', $html);you can use (?!http|mailto) if you have also mailto links in your $html
路上除了风景还有故事
$html = preg_replace("#(<\s*a\s+[^>]*href\s*=\s*[\"'])(?!http)([^\"'>]+)([\"'>]+)#", '$1http://mydomain.com/$2$3', $html);you can use (?!http|mailto) if you have also mailto links in your $html