日期:2014-05-16  浏览次数:20468 次

正则解析的问题,有人能帮忙吗?
我现在有一个网站扒下来的源代码,需要其中的一段数据为
<li class="hot_list_item">
                    <a href="http://epaper.bjnews.com.cn/html/2014-03/06/content_498300.htm?div=-1" target="_blank" class="hot_list_title" ga_event="source_url" ga_label="hot_list" rel="nofollow">公车改革今年启动</a><br>
            </li>

            <li class="hot_list_item">
                    <a href="http://ent.sina.com.cn/s/j/k/2014-03-04/10434105946.shtml" target="_blank" class="hot_list_title" ga_event="source_url" ga_label="hot_list" rel="nofollow">韩娱每周一星:来自“星星”的王子安宰贤</a><br>
            </li>

            <li class="hot_list_item">
                    <a href="http://mil.news.sina.com.cn/2014-03-04/1404767064.html" target="_blank" class="hot_list_title" ga_event="source_url" ga_label="hot_list" rel="nofollow">俄媒称俄或同意美推翻叙利亚政权换克里米亚独立</a><br>
            </li>

            <li class="hot_list_item">
                    <a href="http://mil.huanqiu.com/observation/2014-03/4878777.html" target="_blank" class="hot_list_title" ga_event="source_url" ga_label="hot_list" rel="nofollow">有人说俄曾夺中国领土不可深交 此一时彼一时</a><br>
            </li>

中所有a标签的href和内容
我现在后台的写法为
foreach (Match m in Regex.Matches(str,
        @"(?is)(?<=<li\s*class=hot_list_item\s*?><a\s*href=([""']?)([^""']*?)\1[^>]*?value=([""']?)([^""]*?)\3[^>]*?>.*?</A>(?=.*?</li>)")
            )
        {
            string s=m.Value;
        }

但是貌似这个正则无法实现对其解析,求指点。
------解决方案--------------------

string regex_text = "<\\s*a\\s.*?href\\s*=\\s*[\"\']{1}(?<href>(?(1)(.*?)\\1
------解决方案--------------------
([^\\s\\>]+)))[\"\']{1}[^>]*>?(.*?)</a>";
            string str = "<li class=\"hot_list_item\"><a href=\"http://epaper.bjnews.com.cn/html/2014-03/06/content_498300.htm?div=-1\" target=\"_blank\" class=\"hot_list_title\" ga_event=\"source_url\" ga_label=\"hot_list\" rel=\"nofollow\">公车改革今年启动</a><br></li><li class=\"hot_list_item\"><a href=\"http://ent.sina.com.cn/s/j/k/2014-03-04/10434105946.shtml\" target=\"_blank\" class=\"hot_list_title\" ga_event=\"source_url\" ga_label=\"hot_list\" rel=\"nofollow\">韩娱每周一星:来自“星星”的王子安宰贤</a><br></li><li