[原]用正则得到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;
}
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;
}
QQ:273352165
evlon#126.com
转载请注明出处。