求一个正则表达式 C#分析网站的网页的文章时,只想要文章的文字,不要里面的超级链接,如何去掉比如:中国<a href="http://www.cctv.com">中央电视台</a>新闻我只要:中国中央电视台新闻,不要里面的<a ....>和</a> 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 直接Remove掉 正则表达式<(\w*)(.*?)> </\1> <(\w*)(.*?)> </\1> 就是相当等于 你 的<a href="http://www.cctv.com"></a> 貌似刚回答了一个一样的,也是你发的么?Match m = Regex.Match(@"中国<a href="http://www.cctv.com">中央电视台</a>新闻",@"(?<=<a[^>]+>).*?(?=</a>)");MessageBox.Show(m.Value);//就是你要的 private static void TestRegex03(){ Match m = Regex.Match(@"中国<a href=""http://www.cctv.com"">中央电视台</a>新闻", @"(?<=<a[^>]+>).*?(?=</a>)"); MessageBox.Show(m.Value);//就是你要的} string s = "中国<a href=\"http://www.cctv.com\">中央电视台</a>新闻"; s = System.Text.RegularExpressions.Regex.Replace(s, @"(<a\s{0,}[^>]*?href=['""]?[^'""].*?['""]?\s{0,}[^>]*?>)([^<>]*?)(</a>)", "$2"); Response.Write(s); 有关数值转换的问题 求教鼠标侧键映射到键盘 Visual Studio 2008集成的SQL Server 2005 Express Edition装不上 [求助] 怎么就这么难呢???? 未能找到存储过程,是什么问题? 如何降低信誉分? iphone通过浏览器访问网站提示下载app是怎么做的? 【求助】数据库连接问题 小问题 如何实现Combox下拉列表中选中多个值,以 ‘ ,’分割 像这种web界面在winform中要怎么实现 关于click once安装部署
MessageBox.Show(m.Value);//就是你要的
private static void TestRegex03()
{
Match m = Regex.Match(@"中国<a href=""http://www.cctv.com"">中央电视台</a>新闻", @"(?<=<a[^>]+>).*?(?=</a>)");
MessageBox.Show(m.Value);//就是你要的
}
string s = "中国<a href=\"http://www.cctv.com\">中央电视台</a>新闻";
s = System.Text.RegularExpressions.Regex.Replace(s, @"(<a\s{0,}[^>]*?href=['""]?[^'""].*?['""]?\s{0,}[^>]*?>)([^<>]*?)(</a>)", "$2");
Response.Write(s);