itheima-tools-gdq
Version:
格式化时间,HTMLEscape的功能
36 lines (32 loc) • 630 B
JavaScript
function htmlEscape(htmlStr){
return htmlStr.replace(/<|>|"|&/g,(match)=>{
switch(match){
case "<":
return '<'
case ">":
return '>'
case '"':
return 'quto;'
case '&':
return '&'
}
})
}
function htmlUnEscape(htmlStr){
return htmlStr.replace(/<|>|quto;|&/g,(match)=>{
switch(match){
case "<":
return '<'
case ">":
return '>'
case 'quto;':
return '""'
case '&':
return '&'
}
})
}
module.exports ={
htmlEscape,
htmlUnEscape
}