用正则表达式php替换html文件中的所有url

用正则表达式php替换html文件中的所有url,php,Php,我想用php保存外部html文件 如何使用php搜索并用正则表达式替换所有url href="/web/***/http://blog.domain.com/site/styles-site.css" 其中***是不知道的动态代码 取代 href="site/styles-site.css" 霉菌代码: $html=$url; $content = file_get_contents($html); $newhtml = preg_replace( 'web/-[^-.]*\./' ,

我想用php保存外部html文件 如何使用php搜索并用正则表达式替换所有url

href="/web/***/http://blog.domain.com/site/styles-site.css"
其中***是不知道的动态代码

取代

href="site/styles-site.css"
霉菌代码:

$html=$url;
 $content = file_get_contents($html);


$newhtml = preg_replace( 'web/-[^-.]*\./' , '.' , $content);
file_put_contents('post1.html', $newhtml);

你能再举一些URL的例子吗?是的,比如href=“/web/***/”,href=“/web/***/”