去除HTML代码得函数

 1 None.gif public   static   string  StripHtmlXmlTags( string  content)
 2 ExpandedBlockStart.gifContractedBlock.gif         dot.gif {
 3InBlock.gif            return Regex.Replace(content, "<[^>]+>""", RegexOptions.IgnoreCase | RegexOptions.Compiled);
 4ExpandedBlockEnd.gif        }

 5 None.gif
 6 ContractedBlock.gifExpandedBlockStart.gif         去除html标签 #region 去除html标签
 7InBlock.gif
 8InBlock.gif        // Strip All Tags from a String
 9ExpandedSubBlockStart.gifContractedSubBlock.gif        /**//*
10InBlock.gif         * Takes a string and strips all bbcode and html from the
11InBlock.gif         * the string. Replacing any <br />s with linebreaks.  This
12InBlock.gif         * method is meant to be used by ToolTips to present a
13InBlock.gif         * a stripped-down version of the post.Body
14InBlock.gif         *
15ExpandedSubBlockEnd.gif         */

16ExpandedSubBlockStart.gifContractedSubBlock.gif        /**//// <summary>
17InBlock.gif        /// 去除所有html标签
18InBlock.gif        /// </summary>
19InBlock.gif        /// <param name="stringToStrip"></param>
20ExpandedSubBlockEnd.gif        /// <returns></returns>

21InBlock.gif        public static string StripAllTags(string stringToStrip)
22ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
23InBlock.gif            // paring using RegEx
24InBlock.gif            //
25InBlock.gif            stringToStrip = Regex.Replace(stringToStrip, "</p(?:\\s*)>(?:\\s*)<p(?:\\s*)>""\n\n", RegexOptions.IgnoreCase | RegexOptions.Compiled);
26InBlock.gif            stringToStrip = Regex.Replace(stringToStrip, "<br(?:\\s*)/>""\n", RegexOptions.IgnoreCase | RegexOptions.Compiled);
27InBlock.gif            stringToStrip = Regex.Replace(stringToStrip, "\"""''", RegexOptions.IgnoreCase | RegexOptions.Compiled);
28InBlock.gif            stringToStrip = StripHtmlXmlTags(stringToStrip);
29InBlock.gif            return stringToStrip;
30ExpandedSubBlockEnd.gif        }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值