求助------用正则获取href src
<div class="bImg"><a rel="gal1" class="jqzoom" href="http://image.cn.made-in-china.com/2f0j01MEaQeqtgUTra/%E4%B9%9D%E7%BA%B9%E9%BE%99%E9%BB%91%E5%95%A4%E9%85%92.jpg" target="_blank" title="九纹龙黑啤酒"><img class="imgborderdetails" src="http://image.cn.made-in-china.com/2f1j01MEaQeqtgUTra/%E4%B9%9D%E7%BA%B9%E9%BE%99%E9%BB%91%E5%95%A4%E9%85%92.jpg" border="0" alt="九纹龙黑啤酒" /></a></div>
两个正则表达式 获取这段a标签里的href 和img标签的src
用.net 正则要包含匹配 <div class="bImg">
测试OK 立马结贴
------最佳解决方案-------------------- Regex reg = new Regex(@"(?is)<div class=""bImg"">\s*<a[^>]*?href=""(?<link>[^""]*)""[^>]*>\s*<img[^>]*?src=""(?<src>[^""]*)""[^>]*>");
MatchCollection mc = reg.Matches(yourStr);
foreach (Match m in mc)
{
richTextBox2.Text += m.Groups["link"].Value + "\n";
richTextBox2.Text += m.Groups["src"].Value + "\n";
}
------其他解决方案--------------------1.<div class="bImg"><a[\w\W]+?href="([\w\W]+?)"[\w\W]+?<img[\w\W]+?src="([\w\W]+?)"
2.<div class="bImg">[\w\W]+?</div>
------其他解决方案--------------------
string str = File.ReadAllText("D:\\1.txt", Encoding.Default);
var ary = Regex.Match(str, @"<div\s*class=""bImg"">((?!</div>)([\s\S]*?(<a.*?href=[""']
------其他解决方案--------------------(?is)<div\sclass=(['"]?)bImg\1>.*?<a\b[^>]*?href=(['"]?)(?<href>[^'"]+)\2[^>]*?>.*?<img[^>]*?src=(['"]?)(?<src>[^'"]+)\3[^>]*?>
取 href和 src分组的值
------其他解决方案-------------------- Regex reg = new Regex(@"(?is)<a[^>]*?href=""(?<link>[^""]*)""");
MatchCollection mc = reg.Matches(yourStr);
foreach (Match m in mc)
{
richTextBox2.Text += m.Groups["link"].Value + "\n";
}