正则表达式匹配时,如何去掉引号

ydnh_wan 2012-11-21 07:05:32
我在php中运行如下程序
<?php
$str = '<img src=\'http://xxx/xxx.jpg\' alt=\'\' />';
$soImages = '/\'(.*?)\'/';
preg_match_all( $soImages, $str, $thePics );
$allPics = count($thePics[0]);
if( $allPics > 0 ){
echo $thePics[0][0];
}
?>

返回的结果为'http://xxx/xxx.jpg'
我希望返回结果直接是http://xxx/xxx.jpg
请问如何让正则匹配返回不带单引号的结果?
...全文
516 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
夏之冰雪 2012-11-21
  • 打赏
  • 举报
回复
echo $thePics[1][0];

21,886

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧