当前位置:网站首页>去除富文本标签样式
去除富文本标签样式
2022-08-10 17:39:00 【凡小多】
可以通过正则匹配式,去除简单的富文本的标签样式,返回纯内容格式
// 去除富文本标签样式
const removeHtmlStyle = (html) => {
const relStyle = /style\s*?=\s*?(['"])[\s\S]*?\1/g
const relTag = /<.+?>/g
const relClass = /class\s*?=\s*?(['"])[\s\S]*?\1/g
let newHtml = ''
if (html) {
newHtml = html.replace(relStyle, '')
newHtml = newHtml.replace(relTag, '')
newHtml = newHtml.replace(relClass, '')
}
return newHtml
}
边栏推荐
- 网络层总结(未完待续)
- Toronto Research Chemicals BTK甜味剂配方丨D-Abequose
- 如何学习性能测试?
- 全新接口——邻家好货 API
- Colocate Join :ClickHouse的一种高性能分布式join查询模型
- pip安装时 fatal error C1083 无法打开包括文件 “io.h” No such file or directory
- 多线程与高并发(11)——经典面试题之实现一个容器,提供两个方法,add,size。
- 忍不住 - 发个新帖子【为什么把红圈的功能入口隐藏?需要移动到鼠标到位置驻停才显示?】- 请投票
- 机器人控制器编程整理汇总-辞旧迎新-
- 中国芯片的营收首破万亿,优势凸显的成熟工艺产能将称霸全球
猜你喜欢
随机推荐
The DGIOT platform displays the whole process code analysis of OPC reporting data in real time
测试接口出现“data“: “Full authentication is required to access this resource“凭证已过期
CAS客户端对接
Return the next higher prime number
轮询以及webSocket与socket.io原理
pip安装时 fatal error C1083 无法打开包括文件 “io.h” No such file or directory
浅谈泰山众筹系统开发技术说明及dapp链上众筹系统开发分析
ROBOTSTXT_OBEY[通俗易懂]
Interpretation of ZLMediaKit server source code---RTSP push and pull
MongoDB教程
DeamNet代码学习||网络框架核心代码 逐句查找学习
Mysql index, transaction and storage engine
R语言ggplot2可视化:使用ggpubr包的ggscatter函数可视化分组散点图、stat_mean函数在分组数据点外侧绘制凸包并突出显示分组均值点、自定会均值点的大小以及透明度
Toronto Research Chemicals 双(乙酰丙酮)铂(II)
LeetCode 0640.求解方程:过几天就看不懂了的迷惑性代码,但是是详解
老板加薪!看我做的WPF Loading!!!
架构-三层架构:三层架构
Scala中使用 Jackson API 进行JSON序列化和反序列化
Live Review|How to build an enterprise-level cloud management platform in the multi-cloud era?(with the download of the construction guide)
D-Wave成功上市!量子计算商业化正在加速









