php提取背景图片地址

来源:百度知道 编辑:UC知道 时间:2024/05/04 13:42:31
……background-image:url("http://xxx.com/xxx/xxx");……
用php提取代码中的http://xxx.com/xxx/xxx,正则表达式应该怎么写

下面的测试代码调试通过,正确运行,希望对你有所帮助:

<?php
$s='……background-image:url("http://xxx.com/xxx/xxx");……';
if (preg_match('|background-image:url\("([^"]*)"\)|', $s, $reg)) echo $reg[1];
?>