Home > Backend Development > PHP Tutorial > php 正则匹配 图片有关问题

php 正则匹配 图片有关问题

WBOY
Release: 2016-06-13 10:27:29
Original
1002 people have browsed it

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

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

';
$text = stripslashes($text);
//print_r($text);
$pregfind = array(
"/php 正则匹配 图片有关问题]*file[^>]*)>/eiU",
);
$pregreplace = array(
"img_tag('\\1', '".$url."')",
);
return preg_replace($pregfind, $pregreplace, $text);

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

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


而不要匹配到



------解决方案--------------------
'/php 正则匹配 图片有关问题]*file="([^>]+)"[^>]*>/eiU',
试试这个

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template