日期:2014-05-20  浏览次数:20763 次

正则
..........

<li>
<a   href= "aaaa "> aaaaaaaaa </a>   <a   href= "ppp "> 评 </a>
<a   href= "bbbb "> bbbbbbbbb </a>
<a   href= "cccc "> ccccccccc </a>   <a   href= "ttt "> 讨 </a>
<a   href= "dddd "> ddddddddd </a>
<a   href= "eeee "> eeeeeeeee </a>
<a   href= "ffff "> fffffffff </a>
<a   href= "gggg "> ggggggggg </a>
</li>

............

我要捕获url和title,但是不希望捕获类似 "评 "/ "讨 "这种字符数少于2的 <a> 标记的url和title


<li> (.*? <a   href=\ "(? <Url> [^\ "]+).*?> (? <Title> [^ <]{2,}) </a> ){1,20}?\\s* </li>

上边我写的这个title和url叉了

多谢!!

------解决方案--------------------
Regex reg=new Regex(@ " <a href= " "(? <Url> [^ " "]+) " "> \w{2,} </a> ");
foreach(Match m in reg.Matches(str))
{
str=m.Groups[ "Url "].Value;
str= " ";
}//简简单单就好
------解决方案--------------------
.....late