可以匹配到了到中文名字的图片地址 可以正常工作 有待改进
$str = "账单2018";
//GBK/GB2312使用:
preg_match_all("/[x80-xff]+/", $str, $chinese);
//UTF-8 使用:
//preg_match_all("/[x{4e00}-x{9fa5}]+/u", $str, $chinese);
print_r($chinese);
测试通过 只是有点长了
$str='<p><img src="https://fanyi.c.com/c/爱油中文字的文件名.png" height="30"><img src="http://fanyi.c.com/c/header/logo_cbfea26.png" alt="Firefox" title="Firefox" width="31" height="30"><img src="//fanyi.c.com/c/header/logo_cbfea26.png" ><img src="https://fanyi.c.com/yellow.png" width="31" height="30"><img src="/images/shortname.gif" width="28""><img src="../images/shortname.gif"></p>';
preg_match_all("/(<img[^>]*src[[:blank:]]*)=[[:blank:]]*['"]?(([[a-z]{3,5}://(([.a-zA-Z0-9-])+(:[0-9]+)*))*([+:%/?=&;\(),._a-zA-Z0-9-]([x{4e00}-x{9fa5}p{P}]+)[^'"]*))(#[.a-zA-Z0-9-]*)?['" ]?/ius", $str, $regs);
print_r($regs[2]);
foreach($regs[2] as $val){//remove matched image from origin content
$str = str_replace($val, "", $str);
}
preg_match_all("/(img[^>]*src[[:blank:]]*)=[[:blank:]]*['"]?(([[a-z]{3,5}://(([.a-zA-Z0-9-])+(:[0-9]+)*))*([+:%/?=&;\(),._a-zA-Z0-9-]*))(#[.a-zA-Z0-9-]*)?['" ]?/is", $str, $regs);
foreach($regs[2] as $key=>$val){//remove matched image from origin content
if(empty($val)){
unset($regs[2][$key]);
}
}
print_r($regs[2]);
Array
(
[0] => https://fanyi.c.com/c/爱油中文字的文件名.png
[1] => http://fanyi.c.com/c/header/logo_cbfea26.png
[2] => //fanyi.c.com/c/header/logo_cbfea26.png
[3] => https://fanyi.c.com/yellow.png
[4] => ../images/shortname.gif
)
Array
(
[4] => /images/shortname.gif
)
$str = "账单2018";
//GBK/GB2312使用:
preg_match_all("/[x80-xff]+/", $str, $chinese);
//UTF-8 使用:
//preg_match_all("/[x{4e00}-x{9fa5}]+/u", $str, $chinese);
print_r($chinese);
测试通过 只是有点长了
$str='<p><img src="https://fanyi.c.com/c/爱油中文字的文件名.png" height="30"><img src="http://fanyi.c.com/c/header/logo_cbfea26.png" alt="Firefox" title="Firefox" width="31" height="30"><img src="//fanyi.c.com/c/header/logo_cbfea26.png" ><img src="https://fanyi.c.com/yellow.png" width="31" height="30"><img src="/images/shortname.gif" width="28""><img src="../images/shortname.gif"></p>';
preg_match_all("/(<img[^>]*src[[:blank:]]*)=[[:blank:]]*['"]?(([[a-z]{3,5}://(([.a-zA-Z0-9-])+(:[0-9]+)*))*([+:%/?=&;\(),._a-zA-Z0-9-]([x{4e00}-x{9fa5}p{P}]+)[^'"]*))(#[.a-zA-Z0-9-]*)?['" ]?/ius", $str, $regs);
print_r($regs[2]);
foreach($regs[2] as $val){//remove matched image from origin content
$str = str_replace($val, "", $str);
}
preg_match_all("/(img[^>]*src[[:blank:]]*)=[[:blank:]]*['"]?(([[a-z]{3,5}://(([.a-zA-Z0-9-])+(:[0-9]+)*))*([+:%/?=&;\(),._a-zA-Z0-9-]*))(#[.a-zA-Z0-9-]*)?['" ]?/is", $str, $regs);
foreach($regs[2] as $key=>$val){//remove matched image from origin content
if(empty($val)){
unset($regs[2][$key]);
}
}
print_r($regs[2]);
Array
(
[0] => https://fanyi.c.com/c/爱油中文字的文件名.png
[1] => http://fanyi.c.com/c/header/logo_cbfea26.png
[2] => //fanyi.c.com/c/header/logo_cbfea26.png
[3] => https://fanyi.c.com/yellow.png
[4] => ../images/shortname.gif
)
Array
(
[4] => /images/shortname.gif
)
尊贵的董事大人
英文标题不为空时 视为本栏投稿
需要关键字 描述 英文标题