求一表达式,请高手帮忙!

xnlm2005 2012-02-15 11:33:18
<li class=fk><a href="http://xnlm2004.33591.com" target="_blank"><img src="http://meida2.33591.com/userdata/2012/2/15/16/499611/image/head.gif.small.gif" width="80" height="80" border="0" alt="User" /></a><br /><a href="http://xnlm2004.33591.com" target="_blank">xnlm2004</a></li>

提取xnlm2004
...全文
55 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
欢乐的小猪 2012-02-16
  • 打赏
  • 举报
回复
://xnlm2004.
特征是开头://结尾.
Regex
ayzen1988 2012-02-16
  • 打赏
  • 举报
回复
string abc = @"<li class=fk><a href='http://xnlm2004.33591.com' target='_blank'>
<img src='http://meida2.33591.com/userdata/2012/2/15/16/499611/image/head.gif.small.gif' width='80' height='80' border='0' alt='User' /></a>
<br /><a href='http://xnlm2004.33591.com' target='_blank'>xnlm2004</a></li>";
Match match = Regex.Match(abc, @"(?<='_blank'>).*(?=</a>)");
Console.WriteLine(match.Value);
hundanbaobao001 2012-02-16
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 dalmeeme 的回复:]

有好几处xnlm2004了,是不是<a></a>之间那个,试下:
C# code
string s = @"<li class=fk><a href=""http://xnlm2004.33591.com"" target=""_blank""><img src=""http://meida2.33591.com/userdata/2012/2/15/16/499611/im……
[/Quote]
晚上三天起来回复,伟大。
dalmeeme 2012-02-16
  • 打赏
  • 举报
回复
有好几处xnlm2004了,是不是<a></a>之间那个,试下:
		string s = @"<li class=fk><a href=""http://xnlm2004.33591.com"" target=""_blank""><img src=""http://meida2.33591.com/userdata/2012/2/15/16/499611/image/head.gif.small.gif"" width=""80"" height=""80"" border=""0"" alt=""User"" /></a><br /><a href=""http://xnlm2004.33591.com"" target=""_blank"">xnlm2004</a></li>";
Match match = Regex.Match(s, @"(?is)(?<=<li class=fk>.*?<a[^>]+>)[^<>]+(?=</a></li>)");
Response.Write(match.Value);

110,536

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧