首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

去除字符串中所有超链接!解决方法

2012-03-30 
去除字符串中所有超链接!去除字符串中所有超链接!把字符串中的a....../a 全部去除掉!例子: “去除a..

去除字符串中所有超链接!
去除字符串中所有超链接! 
 把字符串中的 <a>......</a> 全部去除掉!

例子: “去除<a>......</a>字符串<a>......</a>中所有<a>......</a>超链接”

结果为 “去除字符串中所有超链接”

[解决办法]

C# code
            string source = "去除<a>......</a>字符串<a>......</a>中所有<a>......</a>超链接";            Regex reg = new Regex(@"<a>\w*\W*</a>");            source = reg.Replace(source, "");
[解决办法]
C# code
string str = @"<span><a href=""http://www.baidu.com"">baidu</a><font>dfsafsa</font></span><a href=""http://www.baidu.com"">baidu</a>";                 Regex reg = new Regex(@"<a\s*[^>]*>(.*?)</a>");            string res = reg.Replace(str, "");//res="<span><font>dfsafsa</font></span>" 

热点排行