itheima-tools-wxl
Version:
第一个npm包
31 lines (29 loc) • 624 B
JavaScript
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}