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

如何截取网页中所有 A表情地址

某论坛的帖子列表源码如下:
<a href="read.php?tid=162061" name="readlink" id="a_ajax_162069" class="subject_t f14">湖光美景[10P]</a>
<a href="read.php?tid=162062" name="readlink" id="a_ajax_162069" class="subject_t f14">湖光美景[10P]</a>
<a href="read.php?tid=162063" name="readlink" id="a_ajax_162069" class="subject_t f14">湖光美景[10P]</a>
<a href="read.php?tid=162064" name="readlink" id="a_ajax_162069" class="subject_t f14">湖光美景[10P]</a>
<a href="read.php?tid=162065" name="readlink" id="a_ajax_162069" class="subject_t f14">湖光美景[10P]</a>
如何才能截取成:
read.php?tid=162061
read.php?tid=162062
read.php?tid=162063
read.php?tid=162064
read.php?tid=162065

正则我不会写,给个源码,

------解决方案--------------------
foreach(Match m in Regex.Mathes(yourhtml,@"(?i)(?<=<a\b[^>]*?href=(['""]?)[^'""]+(?=\1)"))
{
//m.Value就是你想要的
}
------解决方案--------------------
C# code
foreach(Match m in Regex.Mathes(yourhtml,@"(?i)(?<=<a\b[^>]*?href=(['""]?)[^'""]+(?=\1)"))
{
  //m.Value就是你想要的
}