Remove all the html Tag in String
在用Umbraco开发项目的过程中,由于在Umbraco Back office 中有用到 rich text editor, 而它返回的值是HtmlString类型,也就是说是包含Html Tag的
比如 返回的是 "<p><span>This is a test message</span></p>"
那么,如何来移除掉其中的html tag呢.
我们可以用正则表达式来移除掉其中的html tag
@using System.Text;
@using System.Web; public static class StringTool
{ private static readonly Regex HtmlTag = new Regex(@"<[^>]*>"); public static string RemoveHtmlTag(this string origStr)
{
return string.IsNullOrEmpty(origStr) ? origStr : HttpUtility.HtmlDecode(HtmlTag.Replace(origStr, string.Empty));
} }
上面,我们写了一个扩展方法 RemoveHtmlTag 来移除string中的html tag, 采用了正则表达式HtmlTag
Remove all the html Tag in String的更多相关文章
- [LeetCode] Add Bold Tag in String 字符串中增添加粗标签
Given a string s and a list of strings dict, you need to add a closed pair of bold tag <b> and ...
- LeetCode 616. Add Bold Tag in String
原题链接在这里:https://leetcode.com/problems/add-bold-tag-in-string/description/ 题目: Given a string s and a ...
- 616. Add Bold Tag in String加粗字符串
[抄题]: Given a string s and a list of strings dict, you need to add a closed pair of bold tag <b&g ...
- 【LeetCode】616. Add Bold Tag in String 解题报告(C++)
作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 遍历 日期 题目地址:https://leetcode ...
- [LeetCode] 203. Remove Linked List Elements_Easy tag: Linked LIst
Remove all elements from a linked list of integers that have value val. Example: Input: 1->2-> ...
- 深入探讨:标签(Tag)的各种设计方案
首先,标签(Tag)是什么? 我的理解:用来具体区分某一类内容的标识,和标签类似的一个概念是分类(Category),有一个示例可以很好的区分它们两个,比如人类分为:白种人.黄种人和黑种人(可以看作分 ...
- 标签(Tag)的各种设计方案
标签(Tag)的各种设计方案 首先,标签(Tag)是什么? 我的理解:用来具体区分某一类内容的标识,和标签类似的一个概念是分类(Category),有一个示例可以很好的区分它们两个,比如人类分为:白种 ...
- 没什么技术含量的Remove Before Flight
航空业有很多值得我们借鉴和学习的工作方式,将来有时间我会给大家引荐更多实例. 仔细观察每架停泊着的飞机,会发现机身很多地方都挂着细长的红布条,上面写着"REMOVE BEFORE FLIGH ...
- 【LeetCode】字符串 string(共112题)
[3]Longest Substring Without Repeating Characters (2019年1月22日,复习) [5]Longest Palindromic Substring ( ...
随机推荐
- 顺序表的静态存储(C语言实现)
顺序表是在计算机内存中以数组的形式保存的线性表,是指用一组地址连续的存储单元依次存储数据元素的线性结构. 1.顺序表的结构体声明 #define MAX_SIZE 5 //定义数组的大小 typed ...
- 第二天----列表、深浅拷贝、元组、字符串、算数运算、字典、while
列表 列表是最常用的Python数据类型,它可以作为一个方括号内的逗号分隔值出现. 基本操作: 索引切片追加删除长度切片循环包含 创建.查看列表: 列表中的数字不要加引号,列表的索引从0开始: lis ...
- Win7打开新的文件夹总会以新窗口的形式打开
首先可以在 组织-->文件夹和搜索选项 中设置“在同一窗口中打开每个文件夹” 如果设置后不起作用还可以 管理员方式执行以下两条命令 在开始菜单-运行中输入regsvr32 "%Sy ...
- SpringMVC简单实例(看起来有用)
SpringMVC简单实例(看起来有用) 参考: SpringMVC 基础教程 简单入门实例 - CSDN博客http://blog.csdn.net/swingpyzf/article/detail ...
- HTML5学习笔记——1
1.视频 <vedio src controls height width autoplay loop preload > </vedio> <source src ...
- Centos7部署NFS
server1:192.168.1.189 ###客户端 server2:192.168.1.190 ##服务端 1.首先创建共享目录. mkdir -p /data/share 安装nfs ...
- 201621123014《Java程序设计》第三周学习总结
<Java程序设计>第三周实验报告 1. 本周学习总结 初学面向对象,会学习到很多碎片化的概念与知识.尝试学会使用思维导图将这些碎片化的概念.知识点组织起来.请使用工具画出本周学习到的知识 ...
- leetcode 268 Missing Number(异或运算的应用)
Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missin ...
- 动作基类 CCAction
CCAction动作基类关系 class CC_DLL CCAction : public CCObject { public: CCAction(void); virtual ~CCAction(v ...
- ffmpeg推流命令参数记录
列出我们本机的设备:ffmpeg -list_devices true -f dshow -i dummy .\ffmpeg -r 25 -f dshow -s 640*480 -i video=&q ...