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

你可能感兴趣的文章
Linux网络栈协议无关层--BSD socket
查看>>
SEO知识图一
查看>>
USACO hamming
查看>>
[开源JVM] yvm - 自制Java虚拟机
查看>>
Open vSwitch安装
查看>>
HashMap、HashTable、LinkedHashMap和TreeMap用法和区别
查看>>
document.domain 跨域问题[转]
查看>>
【Android】 No Activity found to handle Intent.
查看>>
Mysql 模糊匹配(字符串str中是否包含子字符串substr)
查看>>
Struts2 Action名称的搜索顺序
查看>>
C++ sort简单用法
查看>>
Oracle分区索引
查看>>
4.17上午
查看>>
IIS的ISAPI接口简介
查看>>
python:open/文件操作
查看>>
16 乘法口诀输出
查看>>
mac 常用地址
查看>>
鼠标经过切换图片
查看>>
流程控制 Day06
查看>>
Linux下安装Tomcat
查看>>