正则表达式提取所有.JPG和.PNG URL [英] Regular Expression to extract all .JPG and .PNG URL's
本文介绍了正则表达式提取所有.JPG和.PNG URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好,
我对正则表达式不好。有人会帮助我:
我需要从字符串中提取所有URL到.jpg和.png图片
包含一个HTML文件(DOM无法正常工作我需要的是什么。
我试过了:
preg_match_all(" /。jpg $ | .png $ /" ,$ htmlfile,$ Matches);
foreach($匹配为$ match)
{
echo $ match。"< br> ;" ;;
}
没有太大的成功。有人可以纠正这个问题吗?
解决方案
| .png
/" ;,
HTMLFILE,
Hello,
I''m bad at regular expressions. Would somebody help me:
I need to extract all URL to .jpg and .png pictures from a string
containing an HTML file (DOM wouldn''t work well in what I need).
I''ve tried:
preg_match_all("/.jpg$|.png$/", $htmlfile, $Matches);
foreach ($Matches as $match)
{
echo $match."<br>";
}
without much success. Anybody can correct this to make it work?
解决方案
|.png
/",
htmlfile,
这篇关于正则表达式提取所有.JPG和.PNG URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文