PHP URL 正则 图片 url
我现在要匹配一个url地址,如:。我只想要src的url地址,还要匹配,有的是这种形式src后面没有““”双引号,有的是单引号,而且alt和title有的标记中是没有的。请问各位这个正则怎么写呢?回复讨论(解决方案)
/((http|https):\/\/)+(\w+\.)+(\w+)[\w\/\.\-]*(jpg|gif|png)/
<?php$str =<<]*>/im';$matches = array();preg_match_all($reg, $str, $matches);print_r($matches);
<?php$str =<<]*>/im';$matches = array();preg_match_all($reg, $str, $matches);print_r($matches);
好像不能匹配
" src='a.jpg' />
<?php$str =<<]*>/im';$matches = array();preg_match_all($reg, $str, $matches);print_r($matches);
好像不能匹配
" src='a.jpg' />
举例子的话最好举一个符合html规范的例子,你说的那个例子无意义。
多谢各位!!!