protected string[] GetSrc(string str)
{
string regStr = " \\<IMG\\ [\\s\\S]*?src=['\"]?(?<p>[^'\" \\>\\ ]+)['\" \\>\\ ]";
string cont1 = string.Empty; //图片的src
Regex reg = new Regex(regStr, RegexOptions.Compiled | RegexOptions.IgnoreCase);
Match match = reg.Match(str);
string picSrc = "";
while (match.Success)
{
picSrc = match.Groups["p"].Value;
cont1 += string.Format("{0}", picSrc + ",");
match = match.NextMatch();
}
cont1 = cont1.Substring(0, cont1.LastIndexOf(','));
string[] strList = cont1.Split(',');
return strList;
{
string regStr = " \\<IMG\\ [\\s\\S]*?src=['\"]?(?<p>[^'\" \\>\\ ]+)['\" \\>\\ ]";
string cont1 = string.Empty; //图片的src
Regex reg = new Regex(regStr, RegexOptions.Compiled | RegexOptions.IgnoreCase);
Match match = reg.Match(str);
string picSrc = "";
while (match.Success)
{
picSrc = match.Groups["p"].Value;
cont1 += string.Format("{0}", picSrc + ",");
match = match.NextMatch();
}
cont1 = cont1.Substring(0, cont1.LastIndexOf(','));
string[] strList = cont1.Split(',');
return strList;
}
转载地址:http://www.cnblogs.com/yhdkzy/archive/2011/03/04/1970858.html