日期:2014-05-18  浏览次数:21239 次

如下获取内容的正则表达式怎么写呢?
<div class="searchresult_list">
<ul class="searchresult_info">
  <li class="hotel_price"><span><dfn>&yen;</dfn>716</span>起<br/><a href="/hotel/7029.html" id="ctl00_MainContentPlaceHolder_hotelList_ctl01_HtmlAnchorHoteldetail" class="base_btns7 all_room_detail" target="_blank" title="香港恒丰酒店(Prudential Hotel)详情">查看详情</a></li>
<li>
<div class="hotel_pic">
<a href="/hotel/7029.html" id="ctl00_MainContentPlaceHolder_hotelList_ctl01_HtmlAnchorHotelNamePic" class="hotel_abbrpic" title="香港恒丰酒店(Prudential Hotel)">
  <img src="http://images3.ctrip.com/hotelimage/7029/C1AD6B94-337E-4788-991A-92003F0D2C78/100/75.jpg" id="ctl00_MainContentPlaceHolder_hotelList_ctl01_HtmlImageHotelPic" style="width: 100px; height: 75px;" alt="香港恒丰酒店(Prudential Hotel)" /></a> 
  <a href="/Domestic/ShowHotelRoomPic.aspx?hotel=7029&type=action&StartDate=2012-2-8&DepDate=2012-2-9" id="ctl00_MainContentPlaceHolder_hotelList_ctl01_HtmlAnchorPic" target="_blank" class="ico_mv" title="香港恒丰酒店(Prudential Hotel)实景图"></a>
</div>
</li>
 
<li class="searchresult_info_name">
<h3 id="ctl00_MainContentPlaceHolder_hotelList_ctl01_goldid" class="searchresult_name hotel_goldmedal">
<a href="/hotel/7029.html" id="ctl00_MainContentPlaceHolder_hotelList_ctl01_HtmlAnchorHotelName" target="_blank" title="香港恒丰酒店(Prudential Hotel)">
  香港恒丰酒店(Prudential Hotel)
  </a>  
 
</h3>
<p class="searchresult_desc_text">香港恒丰酒店位于佐敦港铁站上盖,连接恒丰购物商场,徒步可达尖沙柏丽购物大道。尖沙嘴有各式各样购物热点、商业大厦、特色食府一应俱全。酒店客房简洁舒适,要求便利的客人实属首选。</p>
</li>
 
</ul>
 
 
</div>

我要回去红色部分的内容,怎么写正则表达式呢? 谢谢

------解决方案--------------------
1.
C# code

           //1. span标记
            MatchCollection matchs = Regex.Match("<span[^>]*?>.*?</span>");
            foreach (Match m in matchs)
            {
                Console.WriteLine(m.Value);
            }
            //2. p中的内容
            matchs = Regex.Match("<p[^>]*?>(?<str>.*?)</p>");
            foreach (Match m in matchs)
            {
                Console.WriteLine(m.Groups["str"].Value);
            }

------解决方案--------------------
C# code

            //1. span标记
            MatchCollection matchs = Regex.Match(strHtml, "<span[^>]*?>.*?</span>");
            foreach (Match m in matchs)
            {
                Console.WriteLine(m.Value);
            }
            //2. p中的内容
            matchs = Regex.Match(strHtml, "<p[^>]*?>(?<str>.*?)</p>");
            foreach (Match m in matchs)
            {
                Console.WriteLine(m.Groups["str"].Value);
            }

            //3. a的href和文本。