博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
去除HTML代码得函数
阅读量:4682 次
发布时间:2019-06-09

本文共 1217 字,大约阅读时间需要 4 分钟。

 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        }

转载于:https://www.cnblogs.com/jillzhang/archive/2006/04/12/373132.html

你可能感兴趣的文章
[POJ3281] Dining
查看>>
Ubuntu 14.04 SSH + 远程登录xrdp
查看>>
利用MacBook Air入侵无线网络
查看>>
PAIP.MYSQL SLEEP 连接太多解决
查看>>
说说icon图标
查看>>
C++内联函数
查看>>
25、Django实战第25天:讲师详情页
查看>>
<C++11学习笔记><基础> 右值引用
查看>>
一点儿胡说八道
查看>>
json
查看>>
sourceinsight 头文件和函数注释的宏实现
查看>>
Directx报错01
查看>>
相对路径使用方法
查看>>
JavaScript 博文
查看>>
11款最棒的Linux数据恢复工具
查看>>
项目范围管理(3):如何范围变更与过程控制?
查看>>
Mesos 配置项解析
查看>>
Jquery使用小结
查看>>
Java动态代理
查看>>
堆和栈的差别(转过无数次的文章)
查看>>