<li>
<h4>
<a target="_blank" href="http://ABC.com">凯美瑞DVD</a>
</h4>
<div class="item">
<div class="pic">
<a title="凯美瑞" href="http://" target="_blank">
<img src="http://imgg"/>
</a>
</div>
<div class="desc">
<a target="_blank" href="http://870687" class="permalink">凯美瑞</a>
</div>
<div class="price">
<span> 一口价</span>
<strong>85.00 元</strong> </div>
</div>
</li>
<li>
<h4>
<a target="_blank" href="http://ABC.com">凯美瑞DVD</a>
</h4>
<div class="item">
<div class="pic">
<a title="凯美瑞" href="http://" target="_blank">
<img src="http://imgg"/>
</a>
</div>
<div class="desc">
<a target="_blank" href="http://870687" class="permalink">凯美瑞</a>
</div>
<div class="price">
<span> 一口价</span>
<strong>85.00 元</strong> </div>
</div>
</li>我想从中匹配到h4下的http://ABC.com,和“凯美瑞DVD”这个值...
例如:$(document).ready(function() {
$("h4").each(function() {
alert($(this).html());
});
});
Regex _reg = new Regex(@"(?<=<h4>[\s\S]*?)<a[^>]*?href=(['""])([^'""]+)\1[^>]*?>([^<]*?)</a>(?=[^<]*?</h4>)");
Match m = _reg.Match(tempStr);
string href = m.Groups[2].Value;//http://ABC.com
string text = m.Groups[3].Value;//凯美瑞DVD
那再加上个匹配到图片地址<img src="http://imgg"/>的吧
Regex _reg = new Regex(@"(?<=<h4>[\s\S]*?)<a[^>]*?href=(['""])([^'""]+)\1[^>]*?>([^<]*?)</a>(?=[^<]*?</h4>)[\s\S]*?<div[^>]*?class=(['""])pic\4[^>]*?>[\s\S]*?(<img[^>]*?>)");
Match m = _reg.Match(tempStr);
string href = m.Groups[2].Value;//http://ABC.com
string text = m.Groups[3].Value;//凯美瑞DVD
string img = m.Groups[5].Value;//<img src=\"http://imgg\"/>
Regex _reg = new Regex(@"(?is)<h4>\s*<a\b[^>]*?href=""([^""]*?)""[^>]*?>(.*?)</a>\s*</h4>\s*<div\b[^>]*?>\s*<div\b[^>]*?>\s*<a\b[^>]*?>\s*<img\b[^>]*?src=""([^""]*?)""[^>]*?/>\s*</a>");
Match m = _reg.Match(HtmlStr);
string href = m.Groups[1].Value;//http://ABC.com
string href = m.Groups[2].Value;//凯美瑞DVD
string img= m.Groups[3].Value;//http://imgg
还是再改下吧,换成获取具体的图片地址http://imgg\
Regex _reg = new Regex(@"(?<=<h4>[\s\S]*?)<a[^>]*?href=(['""])([^'""]+)\1[^>]*?>([^<]*?)</a>(?=[^<]*?</h4>)[\s\S]*?<div[^>]*?class=(['""])pic\4[^>]*?>[\s\S]*?<img[^>]*?src=(['""])([^'""]+)\5[^>]*>");
Match m = _reg.Match(tempStr);
string href = m.Groups[2].Value;//http://ABC.com
string text = m.Groups[3].Value;//凯美瑞DVD
string img = m.Groups[6].Value;//http://imgg