读书人

怎么截取网页中所有 A表情地址

发布时间: 2012-08-11 20:50:31 作者: rapoo

如何截取网页中所有 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就是你想要的} 

读书人网 >C#

热点推荐