当前位置:网站首页>富文本样式文字图片处理
富文本样式文字图片处理
2022-07-25 08:45:00 【Moran墨染】
export default const clearStyle = (input) => {
var stringStripper = /(\n|\r| class=(")?Mso[a-zA-Z]+(")? ^p)/g;
var output = input.replace(stringStripper, ' ');
// 2. strip Word generated HTML comments
var commentSripper = new RegExp('<!--(.*?)-->','g');
var output = output.replace(commentSripper, '');
// 3. remove tags leave content if any
var tagStripper = new RegExp('<(/)*(meta|link|span|\\?xml:|st1:|o:|font)(.*?)>','gi');
output = output.replace(tagStripper, '');
// 4. Remove everything in between and including tags '<style(.)style(.)>'
var badTags = ['style', 'script','applet','embed','noframes','noscript'];
for (var i=0; i< badTags.length; i++) {
tagStripper = new RegExp('<'+badTags[i]+'.*?'+badTags[i]+'(.*?)>', 'gi');
output = output.replace(tagStripper, '');
}
// 5. remove attributes ' style="..."'
var badAttributes = ['style', 'start'];
for (var i=0; i< badAttributes.length; i++) {
var attributeStripper = new RegExp(' ' + badAttributes[i] + '="(.*?)"','gi');
output = output.replace(attributeStripper, '');
}
output = output.replace(/<\/?html.*?>/ig,'')
output = output.replace(/<\/?body.*?>/ig,'')
output = output.replace(/<\/?title.*?>/ig,'')
output = output.replace(/<\/?head.*?>/ig,'')
output = output.replace(/<\/?b>/ig,'')
output = output.replace(/<\/?i.*?>/ig,'')
output = output.replace(/[\s]+class=MsoNormal/ig,'')
output = output.replace(/&#[0-9]+;/ig,'')
output = output.replace(/ /ig,'')
output = output.replace(/<p\s+><\/p>/ig,'')
// output = output.replace(/<a .*?>/ig,'')
output = output.replace(/<\/a.*?>/ig,'')
output = output.replace(/<\/?u>/ig,'')
output = output.replace(/<\/pre>/ig,'')
output = output.replace(/<\/?divcourier.*?>?/ig,'')
return output;
}
边栏推荐
- Mongodb database
- NVIDIA programmable reasoning accelerator tensorrt learning notes (II) - practical operation
- OpenGL es to realize the visualization of real-time audio
- IP command usage details
- Graduation project of wechat small program ordering system of small program completion works (6) opening defense ppt
- 附加:中半部分sql语句 区/县(数据表)
- Swift initializer and optional chain
- Keep your Eyes on the Lane: Real-time Attention-guided Lane Detection
- @Use of data annotation (instead of get and set methods in entity classes)
- PHP gets all child nodes under any parent node of the tree structure
猜你喜欢

Huawei device remote login (Telnet, SSH) configuration

016 fundamentals of machine learning mathematics: Introduction

uni-app

Foundation 31: Selenium positioning dynamic ID element

C语言实现二叉平衡树

Idea2021 failed to start. Could not find main class com/intellij/idea/main

SSM+JSP+MYSQL实现的宠物领养收养管理系统源码

LeetCode·83双周赛·6129.全0子数组的数目·数学

Wechat applet ordering system graduation design of applet completion works (2) applet function

Wechat Reservation Reservation of applet completion works applet graduation project (8) graduation project thesis template
随机推荐
华为设备远程登录(Telnet、SSH)配置
51 MCU internal peripherals: timer and counter
Chapter 3 business function development (modifying clues, data echo and modifying data)
This week's big news | FCC exposed Pico 4 VR all-in-one machine, and leipeng's parent company established a smart glasses laboratory
[untitled]
Database query optimization
efcore在Saas系统下多租户零脚本分表分库读写分离解决方案
Idea reads configuration files such as validationmessages.properties Chinese garbled
Record the process of two multi terminal troubleshooting
JVM specification Oracle official website
Redis学习笔记
51单片机内部外设:定时器和计数器
PHP reports an error: classes\phpexcel\cell php Line(594) Invalid cell coordinate ESIGN1
附加:中半部分sql语句 区/县(数据表)
Leetcode · 83 biweekly race · 6129. Number of all 0 subarrays · mathematics
read
Wechat reservation of small program completion works (5) assignment book of small program graduation project
Graduation project of wechat small program ordering system of small program completion works (1) development outline
C语言基础
Solving a random number problem