[原]用正则得到HTML中所有的图片路径

为别人写得,问得人多,记下笔记:

        string strHtml = "";
        Regex rgx 
= new Regex(@"<img.*?src=(?:""|')?(.*?\.(?:jpg|gif)).*?>", RegexOptions.IgnoreCase | RegexOptions.Singleline | RegexOptions.Compiled);

        MatchCollection mc 
= rgx.Matchs(strHtml);
        
foreach (Match m in mc)
        
{
            
string strImgUrl = m.Groups[1].Value;
        }

 

posted @ 2006-09-01 15:59  阿牛  阅读(653)  评论(2编辑  收藏  举报