mdf-tools
Version:
提供了格式化时间、HTMLEscape相关的功能
34 lines (33 loc) • 622 B
JavaScript
// 转义
function htmlEscape(htmlstr) {
return htmlstr.replace(/<|>|"|&/g,ma=>{
switch(ma){
case "<":
return '<'
case '>':
return '>'
case '"':
return '"'
case '&':
return '&'
}
})
}
function htmlUnEscape(str){
return str.replace(/<|>|"|&/g,(ma)=>{
switch(ma){
case '<':
return '<'
case '>':
return '>'
case '"':
return '"'
case '&':
return '&'
}
})
}
module.exports={
htmlEscape,
htmlUnEscape
}