日期:2014-05-18 浏览次数:20412 次
<div class="tb-detail-hd"> <h3><a href="http://detail.tmall.com/venus/spu_detail.htm?spu_id=136191697&no_switch=1&default_item_id=13133052500" target="_blank">【五折】Jack Jones杰克琼斯连帽含羊毛双层毛衣B浅211425001104</a></h3> <p> <span> 举报此商品(<a href="http://support.taobao.com/myservice/suit/accuse_punish.jhtml?auction_num_id=13133052500&display_type=3">举报</a>) </span> </p> </div>
Regex re = new Regex("(?is)<div\\s*class=\"tb-detail-hd\">[^<]+<h3>(.*?)</h3>.*?</div>", RegexOptions.None);
------解决方案--------------------
LZ的那个改一下。。。也可以
Regex re = new Regex("(?is)<div\\s*class=\"tb-detail-hd\">\\s*<h3>(<a[^>]*>)?[^<]*(</a>)?</h3>.*?</div>", RegexOptions.None);
------解决方案--------------------
string strMatch = Regex.Match(strHtml, @"(?<=<div class=""tb-detail-hd"">\s*)<h3>(<a[^>]*>)?([^<]*)(</a>)?</h3>", RegexOptions.IgnoreCase).Value; return strMatch;
------解决方案--------------------
改一下
reg = @"(?is)<div class=""tb-detail-hd""><h3>(<a[^>]*>)?(.*?)(</a>)?</h3></div>";