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

你可能感兴趣的文章
redis sentinel 读写分离
查看>>
团队项目(第五周)
查看>>
ElasticSearch6(三)-- Java API实现简单的增删改查
查看>>
选拔赛 I 点进来吧,这里有你想要的
查看>>
SQL 优化经验总结34条
查看>>
开源 视频会议 收藏
查看>>
核心J2EE模式 - 截取过滤器
查看>>
test1
查看>>
常见反函数、反函数导数(微分)公式
查看>>
【物理】概念的理解 —— 蒸馏、萃取
查看>>
洛谷P2002消息扩散
查看>>
TP框架中field查询字段
查看>>
arm-linux-gcc
查看>>
LeetCode 36 Valid Sudoku(合法的数独)
查看>>
抓其根本(一)(hdu2710 Max Factor 素数 最大公约数 最小公倍数.....)
查看>>
k-window的关闭与打开设置
查看>>
SpringMVC学习系列(6) 之 数据验证
查看>>
二、如何通过URL获取其他网页源代码内容(火狐插件扩展开发教程)
查看>>
重构sql server的sys.sp_helptext存储
查看>>
浅谈JavaWeb架构演变
查看>>