]*)>/eiU", ); $pregreplace = array( "img_t"/>
PHP头条
热点:

php正则匹配图片有关问题


php 正则匹配 图片问题
$text = '

JfW《今日肇庆》对外宣传政府网

';
$text = stripslashes($text);
//print_r($text);
$pregfind = array(
"/]*file[^>]*)>/eiU",
);
$pregreplace = array(
"img_tag('\\1', '".$url."')",
);
return preg_replace($pregfind, $pregreplace, $text);

一直不明白,我想匹配的是

这样的图片,但是上面例子中图片没有file属性,为何正则也匹配到他了?求解。怎么修改正则才只匹配到


而不要匹配到



------解决方案--------------------
'/]*file="([^>]+)"[^>]*>/eiU',
试试这个

www.phpzy.comtrue/phprm/52066.htmlTechArticlephp正则匹配图片有关问题 php 正则匹配 图片问题 $text = ' JfW《今日肇庆》对外宣传政府网 '; $text = stripslashes($text); //print_r($text); $pregfind = array( "/ ]*file[^>]*)>/eiU", ); $pregreplace = array( "img_t...

相关文章

PHP之友评论

今天推荐