cyl-tools
Version:
提供格式化时间,html相关功能
38 lines (33 loc) • 797 B
JavaScript
// 转义 html
function htmlEscape(htmlstr){
return htmlstr.replace(/<|>|"|&/g, (match)=>{
switch (match) {
case '<':
return '<'
case '>':
return '>'
case '"':
return '"'
case '&':
return '&'
}
})
}
function htmlUnEscape(htmlstr){
return htmlstr.replace(/<|>|"|&/g, (match)=>{
switch (match) {
case '<':
return '<'
case '>':
return '>'
case '"':
return '"'
case '&':
return '&'
}
})
}
module.exports = {
htmlEscape,
htmlUnEscape
}