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

你可能感兴趣的文章
Flex 4.x 下载进度不出现问题解决办法
查看>>
Vue之自定义组件的v-model
查看>>
Vue项目碰到"‘webpack-dev-server’不是内部或外部命令,也不是可运行的程序或批处理文件"报错...
查看>>
解决Xcode在ipad/iphone 9.2 系统真机测试时出现could not find developer disk image问题
查看>>
基于asp.net的ajax分页
查看>>
分布式事务,两阶段提交协议,三阶段提交协议
查看>>
php/js获取客户端mac地址的实现代码
查看>>
float 在父元素为inline元素的情况
查看>>
git的基本使用
查看>>
MDK中编译程序后Program Size详解
查看>>
C++设计模式-Strategy策略模式
查看>>
MySQL中优化sql语句查询常用的30种方法
查看>>
字符流
查看>>
weight权重的属性
查看>>
Property和attribute的区别[转]
查看>>
iPhone4 手机应用相关
查看>>
Linux Unix shell 编程指南学习笔记(第四部分)
查看>>
idea的修改文件变颜色
查看>>
linux查看端口号是否被占用
查看>>
response实现文件的下载
查看>>