emo-itheima-tools
Version:
格式化时间和html escape
34 lines (32 loc) • 761 B
JavaScript
function escape(htmlStr){
return htmlStr.replace(/<|>|"|&/g,(m)=>{
switch(m){
case '<':
return '<'
case '>':
return '>'
case '"':
return '"'
case '&':
return '&'
}
})
}
function unEscape(htmlStr){
return htmlStr.replace(/<|>|"|&/g,(m)=>{
switch(m){
case '<':
return '<'
case '>':
return '>'
case '"':
return '"'
case '&':
return '&'
}
})
}
module.exports = {
escape,
unEscape
}