博客
关于我
强烈建议你试试无所不能的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

你可能感兴趣的文章
UML-画类图与交互图的顺序
查看>>
站立会议08
查看>>
杭电1060
查看>>
webdriver test1
查看>>
RFC端口号定义
查看>>
Unity Technologies-提供全面的技术支持服务
查看>>
Mac常用工具
查看>>
js无法获取.net设置的cookie
查看>>
Console-算法[for,if,break]-五个好朋友分苹果
查看>>
Mysql数据库账户权限设置
查看>>
ylb: SQL表的高级查询-子查询
查看>>
清空你的Siri “指纹”
查看>>
import 用法
查看>>
报喜啦~过了!
查看>>
6月7 考试系统
查看>>
mysql 基本操作
查看>>
HTML5 and Websocket
查看>>
zTree async 动态参数处理
查看>>
Oracle学习之常见错误整理
查看>>
Android实例-处理隐藏输入法后不再显示问题(XE8+小米2)
查看>>