zll-tools
Version:
这是一个格式化时间,和还原html特殊字符的包
35 lines (33 loc) • 786 B
JavaScript
// 转意html的方法
function htmlEscape(htmlStr){
return htmlStr.replace(/<|>|"|&/g,math=>{
switch(math){
case '<':
return '<'
case '>':
return '>'
case '"':
return '"'
case '&':
return '&'
}
})
}
function htmlUnEscape(str){
return str.replace(/<|>|&aquet;|&/g,(math)=>{
switch(math){
case '<':
return '<'
case '>':
return '>'
case '&aquet;' :
return '"'
case '&' :
return '&'
}
})
}
module.exports = {
htmlEscape,
htmlUnEscape
}