string str = @"(? <= <img[^>]+src="")[^""]+";
Regex r = new Regex(str, RegexOptions.IgnoreCase);
Match m = r.Match("html代码");
while (m.Success)
{
s.Add(m.Value.ToString());
m = m.NextMatch();
} 为什么提示正在分析“(? <= <img[^>]+src=")[^"]+)”- 无法识别的分组构造。参数名: (? <= <img[^>]+src=")[^"]+) 如何解决。难道是正则式有问题。??
Regex r = new Regex(str, RegexOptions.IgnoreCase);
Match m = r.Match("html代码");
while (m.Success)
{
s.Add(m.Value.ToString());
m = m.NextMatch();
} 为什么提示正在分析“(? <= <img[^>]+src=")[^"]+)”- 无法识别的分组构造。参数名: (? <= <img[^>]+src=")[^"]+) 如何解决。难道是正则式有问题。??
Regex r = new Regex(str, RegexOptions.IgnoreCase);
Match m = r.Match("html代码");
while (m.Success)
{
s.Add(m.Value.ToString());
m = m.NextMatch();
}
string HTML = sr.ReadToEnd();
sr.Close();
stream.Close();
string pattern = @"http:\/\/[^\'\""]*\.jpg";
Regex reg=new Regex (pattern);
bool result = true;
if (reg.IsMatch(HTML))
{
foreach (System.Text.RegularExpressions.Match m in reg.Matches(HTML))
{
if (result)
{
string returnValue = DownloadImage(m.Value.ToString(),resourceId);
if (returnValue == "false")
{ }
else
{
result = false;
}
}
}
}
................
string parent = "<img[\\s\\S]*?src=[\"|'](?<groupName>.*?[\"|'])";
System.Text.RegularExpressions.Regex r = new System.Text.RegularExpressions.Regex(parent);
foreach(System.Text.RegularExpressions.Match match in r.Matches(str))
{
string matchvalue = match.Groups["groupName"].Value;
}