eg:下面是html中的部分,现在需要提取每个<LI><SPAN class="userPic"><A> </A></SPAN></LI>中的title和href的属性值,例如第一个为 : 郎咸平       langxianping  ,请问如何操作?
 
<LI class="userList t2">
            <EM class="ico_num">1</EM>
            <EM class="ico_state "></EM>
            <SPAN class="userPic">
              <A title="郎咸平(@郎咸平") href="/langxianping" rel="郎咸平(@郎咸平") 1333183314493="1" card="1" ctype="2">
                <IMG alt="郎咸平(@郎咸平") src="http://t2.qlogo.cn/mbloghead/30cea038dd2a3fd8dae0/40">
              </A>
            </SPAN>
            <SPAN class="userName">
              <A title="郎咸平(@郎咸平") href="/langxianping" rel="郎咸平(@郎咸平") 1333183314493="51" card="1" ctype="2">郎咸平</A>
            </SPAN>
            <SPAN class="topData">17154863</SPAN>
            <SPAN class="pint">郎咸平,美国宾西法尼亚大学沃顿商学院博士,现任香港中...</SPAN>
            <DIV class="attentBox">
              <INPUT style="DISPLAY: none" class="addAttention" value="收听"<i class=\'l\'></i>" type=button><A class='delAttention' href="http://t.qq.com/rank.php?id=5&amp;p=1#">
                取消<I class="l"></I>
              </A><A class="delAttention" href="#">
                取消<I class="\'l\'"></I>
              </A>
            </DIV>
          </LI>
          <LI class="userList t2">
            <EM class="ico_num">2</EM>
            <EM class="ico_state "></EM>
            <SPAN class="userPic">
              <A title="任志强(@任志强") href="/renzhiqiang" rel="任志强(@任志强") 1333183314493="2" card="1" ctype="2">
                <IMG alt="任志强(@任志强") src="http://t3.qlogo.cn/mbloghead/43d038e3bcf59c7f09b8/40">
              </A>
            </SPAN>
            <SPAN class="userName">
              <A title="任志强(@任志强") href="/renzhiqiang" rel="任志强(@任志强") 1333183314493="52" card="1" ctype="2">任志强</A>
            </SPAN>
            <SPAN class="topData">7978901</SPAN>
            <SPAN class="pint">任志强,北京市政协委员,现任华远地产股份有限公司董事...</SPAN>
            <DIV class="attentBox">
              <INPUT style="DISPLAY: none" class="addAttention" value="收听"<i class=\'l\'></i>" type=button><A class='delAttention' href="http://t.qq.com/rank.php?id=5&amp;p=1#">
                取消<I class="l"></I>
              </A><A class="delAttention" href="#">
                取消<I class="\'l\'"></I>
              </A>
            </DIV>
          </LI>

解决方案 »

  1.   


            static void Main(string[] args)
            {
                string htmlStr = @"你的HTML代码";          
                Regex re = new Regex(@"(?is)<LI[^>]+>.*?<SPAN\s*class=""userPic"">\s*<a\s*title=""([^""]+)""\)\s*href=""([^""]+)"".*?</LI>", RegexOptions.None);
                MatchCollection mc = re.Matches(htmlStr);
                foreach (Match ma in mc)
                {
                    Console.WriteLine(ma.Groups[1].Value);
                    Console.WriteLine(ma.Groups[2].Value);
                }
                Console.ReadLine();
            }
    //结果:郎咸平(@郎咸平  /langxianping   
    //      任志强(@任志强  /renzhiqiang
      

  2.   


            static void Main(string[] args)
            {
                string htmlStr = @"你的HTML代码";   
                Regex re = new Regex(@"(?is)<LI[^>]+>.*?<SPAN\s*class=""userPic"">\s*<a\s*title=""([^\(]+)\(@[^""]+""\)\s*href=""/([^""]+)"".*?</LI>", RegexOptions.IgnoreCase);
                MatchCollection mc = re.Matches(htmlStr);
                foreach (Match ma in mc)
                {
                    Console.WriteLine(ma.Groups[1].Value);
                    Console.WriteLine(ma.Groups[2].Value);
                }
                Console.ReadLine();
            }
    //结果:郎咸平  langxianping   
    //      任志强 renzhiqiang
      

  3.   

    刚刚我试了一下,不行样,该段html代码前还有一段,如下:<DIV class=w_head_outer>
    <DIV class=headWrap>
    <DIV id=header class=headInside>
    <H1><A accessKey=z title=t.qq.com onmousedown="MI.Bos('btnClickNewLogo')" href="http://t.qq.com/sky_2011_sky">腾讯微博</A> </H1>
    <UL class=topNav>
    <LI class=topNavItem><A href="http://t.qq.com/sky_2011_sky"><U>首页</U><I></I></A> </LI>
    <LI class=topNavItem><A href="http://t.qq.com/c/default"><U style="PADDING-RIGHT: 15px">广场</U><I></I></A><SUP class=ico_new_sr></SUP> </LI>
    <LI class="topNavItem groups"><A onmousedown="MI.Bos('btnTopMenuGroup')" href="http://qun.t.qq.com"><U>微群<EM>&nbsp;</EM></U><I></I></A> 
    <DIV style="POSITION: absolute; WIDTH: 310px; DISPLAY: none; TOP: 100%; LEFT: 0px" class="topNavSub lay_topdrop_qun"><BR><BR><BR><BR></DIV></LI>
    <LI class=topNavItem><A class=active href="http://t.qq.com/people"><U>找人</U><I></I></A> </LI>
    <LI id=app class="topNavItem apps"><A onmousedown="MI.Bos('btnTopMenuApp')" href="http://app.t.qq.com"><U>应用<EM>&nbsp;</EM></U><I></I></A> 
    <DIV style="DISPLAY: none; TOP: 100%; LEFT: 0px" class=topNavSub>
    <DIV class="itemBox clear"><BR><BR><BR><BR></DIV>
    <DIV class=func>
    <DIV class=clear>
    <P class=right><A href="http://app.t.qq.com/" target=_blank>应用频道<SPAN class=ffsong>&gt;&gt;</SPAN></A></P>
    <P class=left><A href="http://app.t.qq.com/?g=2" target=_blank>进入我的应用</A></P></DIV></DIV></DIV></LI>
    <LI class=topNavItem><A href="http://p.t.qq.com/client.php?t=mobile"><U>手机</U><I></I></A> </LI></UL>
    <UL class="topNav right">
    <LI style="DISPLAY: none" class="topNavItem countItem topNavMsg"><A class="defaultCur txt" title=消息 href="#"><U><STRONG>0</STRONG></U><I></I></A> </LI>
    <LI id=topNav1 class="topNavItem accountItem"><A class=txt title=杨显(@sky_2011_sky) onclick="if(document.body.className.indexOf('ipad') != -1){this.nextSibling.style.display='block';this.className+=' active';return false}" href="http://t.qq.com/sky_2011_sky?preview"><U>杨显<EM>&nbsp;</EM></U><I></I></A>
    <UL style="DISPLAY: none" class=topNavSub>
    <LI><A onmousedown="MI.Bos('btn_settingNewNav');" href="http://t.qq.com/setting">设置</A> </LI>
    <LI><A id=setTheme title=皮肤设置 onmousedown="window.scrollTo(0,0);MI.Bos('btn_themeNewNav');" href="#">换肤</A> </LI>
    <LI><A href="http://t.qq.com/help.php">帮助</A> </LI>
    <LI><A href="http://t.qq.com/logout.php">退出</A> </LI></UL></LI></UL>
    <DIV class=tSearchNew>
    <FORM id=searchForm method=get action=http://t.qq.com/search/index.php><LABEL for=searchKey>搜名字/帐号/广播</LABEL><INPUT accessKey=s id=searchKey class=inputTxtNew maxLength=50 name=k autocomplete="off"> <INPUT value=174 type=hidden name=pos> <INPUT class=inputBtn value=搜索 type=submit> <A class=btn_ldrop href="#"><EM></EM></A></FORM></DIV>
    <DIV id=nav_pub_wrap class=nav_pub_wrap><A class=btn_nav_pub title=写微博 href="#"><EM class=nav_pub_btn>写微博</EM><B class=nav_pub_bg1></B><B class=nav_pub_bg2></B> </A></DIV></DIV><A style="Z-INDEX: 101; POSITION: absolute; FONT-SIZE: 14px; TOP: 7px; RIGHT: 20px" id=testVersion class=testVersion onclick=" MI.Bos('btn_gotoNano_Level3Blow'); " href="http://1.t.qq.com">体验版<SPAN class=ico_new_sr><EM></EM></SPAN></A> 
    <DIV class=headShadow></DIV></DIV></DIV>
    <DIV id=topWrap>
    <DIV id=mainWrapper class=whiteBg>
    <DIV class=navArr><EM></EM></DIV><!--
        <div class="searchWrap">
            <div class="searchTab">
                <ul class="clear"><li class="select"><a href="#">姓名/帐号</a></li><li><a href="#">同道中人</a></li><li><a href="#">校友</a></li><li><a href="#">同事</a></li></ul>
            </div>
            <div class="searchBox">
                <form id="f1" action="/search/user.php" method="get">
                    <div style="display:none">
                        <div class="clear">
                            <input type="text" class="inputTxt" maxlength="50" rel="输入姓名或帐号" value="输入姓名或帐号" name="k" id="k2" autocomplete="off" /><input class="btn3 btnSend" type="submit" value="找人"/><input type="hidden" name="pos" value="601" />
                            <span class="black">想找更多的朋友来分享微博吗?马上<a href="/invite/friends.php">邀请好友开通</a></span>
                        </div>
                    </div>
                </form>
    <form action="/search/user.php" method="get"><input type="hidden" name="pos" value="602" /><input type="hidden" name="keyType" value="4" />
                    <div style="display:none">
                    <div class="clear">
                        <input type="text" name="t" value="输入标签" rel="输入标签" class="inputTxt"><button class="btn3 btnSend" type="submit">找人</button>
                    </div><div class="topicBox clear"><a href="/search/user.php?pos=603&keyType=4&t=IT%E6%B0%91%E5%B7%A5">IT民工<em>(342752)</em></a><a href="/search/user.php?pos=603&keyType=4&t=%E5%90%AC%E9%9F%B3%E4%B9%90">听音乐<em>(14309266)</em></a><a href="/search/user.php?pos=603&keyType=4&t=%E6%97%85%E6%B8%B8">旅游<em>(6278608)</em></a><a href="/search/user.php?pos=603&keyType=4&t=%E7%9C%8B%E4%B9%A6">看书<em>(3254711)</em></a><a href="/search/user.php?pos=603&keyType=4&t=%E6%8A%80%E6%9C%AF%E5%AE%85">技术宅<em>(205139)</em></a><a href="/search/user.php?pos=603&keyType=4&t=80%E5%90%8E">80后<em>(5082090)</em></a><a href="/search/user.php?pos=603&keyType=4&t=%E7%88%AC%E5%B1%B1">爬山<em>(2078516)</em></a></div>                </div>
    </form>
    <form action="/search/user.php" method="get">
                    <div style="display:none">
                    <div class="clear"><input type="hidden" name="pos" value="606" /><input type="hidden" name="high" value="1" />
                        <input type="text" name="k" value="姓名" rel="姓名" class="inputTxt"><input type="text" name="school" value="学校" rel="学校" id="schoolOne" class="inputTxt leftMargin" autocomplete="off"><button class="btn3 btnSend" type="submit">找人</button></div>                </div>
    </form>
    <form action="/search/user.php" method="get">
                    <div style="display:none">
                    <div class="clear"><input type="hidden" name="pos" value="609" /><input type="hidden" name="high" value="1" />
                        <input type="text" name="k" value="姓名" rel="姓名" class="inputTxt"><input type="text" name="c" value="公司" rel="公司" id="cOne" class="inputTxt leftMargin" autocomplete="off"><button class="btn3 btnSend" type="submit">找人</button></div>                </div>
    </form>
    </div>
        </div>
    --><!-- <div class="tabStyle2"><ul><li><a href="/people">认证用户</a></li><li><a href="/potential.php">可能认识</a></li><li style="display:none"><a href="/people?more=1.2.4">分类推荐</a></li><li style="display:none"><a href="/findUserAdv.php">高级搜索</a></li><li class="select"><b>排行榜</b></li><li><a href="/lists.php">名单广场</a></li><li><a href="/list2.php" onclick="MI.Bos('btnPeopleTab5');">特别推荐</a></li><li></a></li></ul><span class="right"><a href="/certification"><em class="vip"></em>我要认证</a></span></div> -->
    <DIV class=tabStyle2>
    <UL>
    <LI><A onclick="MI.Bos('btnPeopleTab1')" href="/find/friends.php">寻找朋友</A> </LI>
    <LI><A onclick="MI.Bos('btnPeopleTab2')" href="/find/interest.php">可能感兴趣</A> </LI>
    <LI><A onclick="MI.Bos('btnPeopleTab3')" href="/people.php">认证用户</A> </LI>
    <LI class=select><B>排行榜</B> </LI>
    <LI><A href="/find/search.php">高级搜索</A> </LI></UL>
    <DIV class=shareSearch>
    <FORM id=f1 onsubmit="if($('schPut').value == '输入姓名/帐号') $('schPut').value = '';" method=get action=/search/user.php><INPUT id=schPut class=inputTxt title=输入姓名/帐号 value=输入姓名/帐号 maxLength=50 name=k autocomplete="off"> <INPUT value=601 type=hidden name=pos> <SPAN class=atbtn><INPUT class=btn_search2 type=submit></SPAN> </FORM></DIV></DIV><!--end tabStyle2Div-->
    <DIV class=subTab1><A href="/rank.php">首页</A> <A href="/rank.php?id=0">全部</A> <A href="/rank.php?id=4">娱乐</A> <A href="/rank.php?id=1">体育</A> <A class=cur href="/rank.php?id=5">财经</A> <A href="/rank.php?id=2">文化</A> <A href="/rank.php?id=12">媒体人</A> <A href="/rank.php?id=13">媒体机构</A> <A href="/rank.php?id=16">公共名人</A> <A href="/rank.php?id=8">时尚</A> <A href="/rank.php?id=3">汽车</A> <A href="/rank.php?id=10">科技</A> <A href="/rank.php?id=17">营销</A> <A href="/rank.php?id=14">政府机构</A> <A href="/rank.php?id=15">公务人员</A> <A href="/rank.php?id=6">动漫</A> <A href="/rank.php?id=11">游戏</A> <A href="/rank.php?id=7">星座</A> <A href="/rank.php?id=9">教育</A> <A href="/rank.php?id=18">企业</A> <A href="/rank.php?id=19">草根</A> <SPAN class=bg></SPAN></DIV>
    <DIV class="topWrap clear">
    <DIV class=topListBox>
    <H3><SPAN class=topTitle>财经热度总榜</SPAN> <SPAN class="topTit lnum">听众总数</SPAN><SPAN class="topTit pint">人物介绍</SPAN><SPAN class="topTit opt"></SPAN></H3>
    <OL class="topList topTotal">
      

  4.   


     static void Main(string[] args)
            {
                string htmlStr = @"你的HTML代码";   
                Regex re = new Regex(@"(?is)<LI\s*class=""userList t2"">.*?<SPAN\s*class=""userPic"">\s*<a\s*title=""([^\(]+)\(@[^""]+""\)\s*href=""/([^""]+)"".*?</LI>", RegexOptions.None);
                MatchCollection mc = re.Matches(htmlStr);
                foreach (Match ma in mc)
                {
                    Console.WriteLine(ma.Groups[1].Value);
                    Console.WriteLine(ma.Groups[2].Value);
                }
                Console.ReadLine();
            }
      

  5.   

    我测试了一下,可以的啊
    C盘建了一个1.txt<DIV class=w_head_outer>
    <DIV class=headWrap>
    <DIV id=header class=headInside>
    <H1><A accessKey=z title=t.qq.com onmousedown="MI.Bos('btnClickNewLogo')" href="http://t.qq.com/sky_2011_sky">腾讯微博</A> </H1>
    <UL class=topNav>
    <LI class=topNavItem><A href="http://t.qq.com/sky_2011_sky"><U>首页</U><I></I></A> </LI>
    <LI class=topNavItem><A href="http://t.qq.com/c/default"><U style="PADDING-RIGHT: 15px">广场</U><I></I></A><SUP class=ico_new_sr></SUP> </LI>
    <LI class="topNavItem groups"><A onmousedown="MI.Bos('btnTopMenuGroup')" href="http://qun.t.qq.com"><U>微群<EM>&nbsp;</EM></U><I></I></A> 
    <DIV style="POSITION: absolute; WIDTH: 310px; DISPLAY: none; TOP: 100%; LEFT: 0px" class="topNavSub lay_topdrop_qun"><BR><BR><BR><BR></DIV></LI>
    <LI class=topNavItem><A class=active href="http://t.qq.com/people"><U>找人</U><I></I></A> </LI>
    <LI id=app class="topNavItem apps"><A onmousedown="MI.Bos('btnTopMenuApp')" href="http://app.t.qq.com"><U>应用<EM>&nbsp;</EM></U><I></I></A> 
    <DIV style="DISPLAY: none; TOP: 100%; LEFT: 0px" class=topNavSub>
    <DIV class="itemBox clear"><BR><BR><BR><BR></DIV>
    <DIV class=func>
    <DIV class=clear>
    <P class=right><A href="http://app.t.qq.com/" target=_blank>应用频道<SPAN class=ffsong>&gt;&gt;</SPAN></A></P>
    <P class=left><A href="http://app.t.qq.com/?g=2" target=_blank>进入我的应用</A></P></DIV></DIV></DIV></LI>
    <LI class=topNavItem><A href="http://p.t.qq.com/client.php?t=mobile"><U>手机</U><I></I></A> </LI></UL>
    <UL class="topNav right">
    <LI style="DISPLAY: none" class="topNavItem countItem topNavMsg"><A class="defaultCur txt" title=消息 href="#"><U><STRONG>0</STRONG></U><I></I></A> </LI>
    <LI id=topNav1 class="topNavItem accountItem"><A class=txt title=杨显(@sky_2011_sky) onclick="if(document.body.className.indexOf('ipad') != -1){this.nextSibling.style.display='block';this.className+=' active';return false}" href="http://t.qq.com/sky_2011_sky?preview"><U>杨显<EM>&nbsp;</EM></U><I></I></A>
    <UL style="DISPLAY: none" class=topNavSub>
    <LI><A onmousedown="MI.Bos('btn_settingNewNav');" href="http://t.qq.com/setting">设置</A> </LI>
    <LI><A id=setTheme title=皮肤设置 onmousedown="window.scrollTo(0,0);MI.Bos('btn_themeNewNav');" href="#">换肤</A> </LI>
    <LI><A href="http://t.qq.com/help.php">帮助</A> </LI>
    <LI><A href="http://t.qq.com/logout.php">退出</A> </LI></UL></LI></UL>
    <DIV class=tSearchNew>
    <FORM id=searchForm method=get action=http://t.qq.com/search/index.php><LABEL for=searchKey>搜名字/帐号/广播</LABEL><INPUT accessKey=s id=searchKey class=inputTxtNew maxLength=50 name=k autocomplete="off"> <INPUT value=174 type=hidden name=pos> <INPUT class=inputBtn value=搜索 type=submit> <A class=btn_ldrop href="#"><EM></EM></A></FORM></DIV>
    <DIV id=nav_pub_wrap class=nav_pub_wrap><A class=btn_nav_pub title=写微博 href="#"><EM class=nav_pub_btn>写微博</EM><B class=nav_pub_bg1></B><B class=nav_pub_bg2></B> </A></DIV></DIV><A style="Z-INDEX: 101; POSITION: absolute; FONT-SIZE: 14px; TOP: 7px; RIGHT: 20px" id=testVersion class=testVersion onclick=" MI.Bos('btn_gotoNano_Level3Blow'); " href="http://1.t.qq.com">体验版<SPAN class=ico_new_sr><EM></EM></SPAN></A> 
    <DIV class=headShadow></DIV></DIV></DIV>
    <DIV id=topWrap>
    <DIV id=mainWrapper class=whiteBg>
    <DIV class=navArr><EM></EM></DIV><!--
        <div class="searchWrap">
            <div class="searchTab">
                <ul class="clear"><li class="select"><a href="#">姓名/帐号</a></li><li><a href="#">同道中人</a></li><li><a href="#">校友</a></li><li><a href="#">同事</a></li></ul>
            </div>
            <div class="searchBox">
                <form id="f1" action="/search/user.php" method="get">
                    <div style="display:none">
                        <div class="clear">
                            <input type="text" class="inputTxt" maxlength="50" rel="输入姓名或帐号" value="输入姓名或帐号" name="k" id="k2" autocomplete="off" /><input class="btn3 btnSend" type="submit" value="找人"/><input type="hidden" name="pos" value="601" />
                            <span class="black">想找更多的朋友来分享微博吗?马上<a href="/invite/friends.php">邀请好友开通</a></span>
                        </div>
                    </div>
                </form>
                <form action="/search/user.php" method="get"><input type="hidden" name="pos" value="602" /><input type="hidden" name="keyType" value="4" />
                    <div style="display:none">
                    <div class="clear">
                        <input type="text" name="t" value="输入标签" rel="输入标签" class="inputTxt"><button class="btn3 btnSend" type="submit">找人</button>
                    </div><div class="topicBox clear"><a href="/search/user.php?pos=603&keyType=4&t=IT%E6%B0%91%E5%B7%A5">IT民工<em>(342752)</em></a><a href="/search/user.php?pos=603&keyType=4&t=%E5%90%AC%E9%9F%B3%E4%B9%90">听音乐<em>(14309266)</em></a><a href="/search/user.php?pos=603&keyType=4&t=%E6%97%85%E6%B8%B8">旅游<em>(6278608)</em></a><a href="/search/user.php?pos=603&keyType=4&t=%E7%9C%8B%E4%B9%A6">看书<em>(3254711)</em></a><a href="/search/user.php?pos=603&keyType=4&t=%E6%8A%80%E6%9C%AF%E5%AE%85">技术宅<em>(205139)</em></a><a href="/search/user.php?pos=603&keyType=4&t=80%E5%90%8E">80后<em>(5082090)</em></a><a href="/search/user.php?pos=603&keyType=4&t=%E7%88%AC%E5%B1%B1">爬山<em>(2078516)</em></a></div>                </div>
                </form>
                <form action="/search/user.php" method="get">
                    <div style="display:none">
                    <div class="clear"><input type="hidden" name="pos" value="606" /><input type="hidden" name="high" value="1" />
                        <input type="text" name="k" value="姓名" rel="姓名" class="inputTxt"><input type="text" name="school" value="学校" rel="学校" id="schoolOne" class="inputTxt leftMargin" autocomplete="off"><button class="btn3 btnSend" type="submit">找人</button></div>                </div>
                </form>
                <form action="/search/user.php" method="get">
                    <div style="display:none">
                    <div class="clear"><input type="hidden" name="pos" value="609" /><input type="hidden" name="high" value="1" />
                        <input type="text" name="k" value="姓名" rel="姓名" class="inputTxt"><input type="text" name="c" value="公司" rel="公司" id="cOne" class="inputTxt leftMargin" autocomplete="off"><button class="btn3 btnSend" type="submit">找人</button></div>                </div>
                </form>
            </div>
        </div>
    --><!-- <div class="tabStyle2"><ul><li><a href="/people">认证用户</a></li><li><a href="/potential.php">可能认识</a></li><li style="display:none"><a href="/people?more=1.2.4">分类推荐</a></li><li style="display:none"><a href="/findUserAdv.php">高级搜索</a></li><li class="select"><b>排行榜</b></li><li><a href="/lists.php">名单广场</a></li><li><a href="/list2.php" onclick="MI.Bos('btnPeopleTab5');">特别推荐</a></li><li></a></li></ul><span class="right"><a href="/certification"><em class="vip"></em>我要认证</a></span></div> -->
    <DIV class=tabStyle2>
    <UL>
    <LI><A onclick="MI.Bos('btnPeopleTab1')" href="/find/friends.php">寻找朋友</A> </LI>
    <LI><A onclick="MI.Bos('btnPeopleTab2')" href="/find/interest.php">可能感兴趣</A> </LI>
    <LI><A onclick="MI.Bos('btnPeopleTab3')" href="/people.php">认证用户</A> </LI>
    <LI class=select><B>排行榜</B> </LI>
    <LI><A href="/find/search.php">高级搜索</A> </LI></UL>
    <DIV class=shareSearch>
    <FORM id=f1 onsubmit="if($('schPut').value == '输入姓名/帐号') $('schPut').value = '';" method=get action=/search/user.php><INPUT id=schPut class=inputTxt title=输入姓名/帐号 value=输入姓名/帐号 maxLength=50 name=k autocomplete="off"> <INPUT value=601 type=hidden name=pos> <SPAN class=atbtn><INPUT class=btn_search2 type=submit></SPAN> </FORM></DIV></DIV><!--end tabStyle2Div-->
    <DIV class=subTab1><A href="/rank.php">首页</A> <A href="/rank.php?id=0">全部</A> <A href="/rank.php?id=4">娱乐</A> <A href="/rank.php?id=1">体育</A> <A class=cur href="/rank.php?id=5">财经</A> <A href="/rank.php?id=2">文化</A> <A href="/rank.php?id=12">媒体人</A> <A href="/rank.php?id=13">媒体机构</A> <A href="/rank.php?id=16">公共名人</A> <A href="/rank.php?id=8">时尚</A> <A href="/rank.php?id=3">汽车</A> <A href="/rank.php?id=10">科技</A> <A href="/rank.php?id=17">营销</A> <A href="/rank.php?id=14">政府机构</A> <A href="/rank.php?id=15">公务人员</A> <A href="/rank.php?id=6">动漫</A> <A href="/rank.php?id=11">游戏</A> <A href="/rank.php?id=7">星座</A> <A href="/rank.php?id=9">教育</A> <A href="/rank.php?id=18">企业</A> <A href="/rank.php?id=19">草根</A> <SPAN class=bg></SPAN></DIV>
    <DIV class="topWrap clear">
    <DIV class=topListBox>
    <H3><SPAN class=topTitle>财经热度总榜</SPAN> <SPAN class="topTit lnum">听众总数</SPAN><SPAN class="topTit pint">人物介绍</SPAN><SPAN class="topTit opt"></SPAN></H3>
    <OL class="topList topTotal">
    <LI class="userList t2">
                <EM class="ico_num">1</EM>
                <EM class="ico_state "></EM>
                <SPAN class="userPic">
                  <A title="郎咸平(@郎咸平") href="/langxianping" rel="郎咸平(@郎咸平") 1333183314493="1" card="1" ctype="2">
                    <IMG alt="郎咸平(@郎咸平") src="http://t2.qlogo.cn/mbloghead/30cea038dd2a3fd8dae0/40">
                  </A>
                </SPAN>       
      

  6.   


      <SPAN class="userName">
                  <A title="郎咸平(@郎咸平") href="/langxianping" rel="郎咸平(@郎咸平") 1333183314493="51" card="1" ctype="2">郎咸平</A>
                </SPAN>
                <SPAN class="topData">17154863</SPAN>
                <SPAN class="pint">郎咸平,美国宾西法尼亚大学沃顿商学院博士,现任香港中...</SPAN>
                <DIV class="attentBox">
                  <INPUT style="DISPLAY: none" class="addAttention" value="收听"<i class=\'l\'></i>" type=button><A class='delAttention' href="http://t.qq.com/rank.php?id=5&amp;p=1#">
                    取消<I class="l"></I>
                  </A><A class="delAttention" href="#">
                    取消<I class="\'l\'"></I>
                  </A>
                </DIV>
              </LI>
              <LI class="userList t2">
                <EM class="ico_num">2</EM>
                <EM class="ico_state "></EM>
                <SPAN class="userPic">
                  <A title="任志强(@任志强") href="/renzhiqiang" rel="任志强(@任志强") 1333183314493="2" card="1" ctype="2">
                    <IMG alt="任志强(@任志强") src="http://t3.qlogo.cn/mbloghead/43d038e3bcf59c7f09b8/40">
                  </A>
                </SPAN>
                <SPAN class="userName">
                  <A title="任志强(@任志强") href="/renzhiqiang" rel="任志强(@任志强") 1333183314493="52" card="1" ctype="2">任志强</A>
                </SPAN>
                <SPAN class="topData">7978901</SPAN>
                <SPAN class="pint">任志强,北京市政协委员,现任华远地产股份有限公司董事...</SPAN>
                <DIV class="attentBox">
                  <INPUT style="DISPLAY: none" class="addAttention" value="收听"<i class=\'l\'></i>" type=button><A class='delAttention' href="http://t.qq.com/rank.php?id=5&amp;p=1#">
                    取消<I class="l"></I>
                  </A><A class="delAttention" href="#">
                    取消<I class="\'l\'"></I>
                  </A>
                </DIV>
              </LI>
               string input = File.ReadAllText(@"C:\1.txt", System.Text.Encoding.GetEncoding("GB2312"));
                string pat = @"(?is)<LI\s*class=""userList t2"">.*?<SPAN\s*class=""userPic"">\s*<a\s*title=""([^\(]+)\(@[^""]+""\)\s*href=""/([^""]+)""(.*?)</LI>";
                MatchCollection matches = Regex.Matches(input, pat);
                Dictionary<string, string> matchstr = new Dictionary<string, string>();
                foreach (Match match in matches)
                {
                    matchstr.Add(match.Groups[1].Value, match.Groups[2].Value);
                }
      

  7.   

    现在的问题是,我用的txt保存的从网页中提取的html,运行不出结果。但是我把该html保存为.xml文件在vs2010中格式化内容后,就可以得到结果,有什么好的方法可以直接运行原来没有格式化的html?
      

  8.   

    正则不涉及这些东西啊,你html保存txt内容难道和上面的不一样?
      

  9.   

    JAVASCRIPT  通过document.getElementbyid 可以获得
      然后把控件  加一个  runat=server  通过后台获取
      

  10.   

    对,txt保存的html没有上面的html有缩进
      

  11.   

    就是没有空白字符,也是可以的啊,只要没有乱码影响,
    (is?)意思是i表示不区分大小写,s所有文本看做单行。\s表示空白字符,比如空格 \r \t这种
    \s*表示0个或者多个\s