getong-tool1
Version:
提供了格式化时间,HTMLEscape相关的内容
42 lines (34 loc) • 860 B
JavaScript
//定义转义HTML字符的函数
function htmlEscape(htmlstr)
{
return htmlstr.replace(/<|>|"|&/g, match=>{
switch(match){
case '<':
return '<'
case '>':
return '>'
case '"':
return '"'
case'&':
return '&'
}
})
}
function htmlRecover(htmlstr){
return htmlstr.replace(/<|>|"|&/g, match=>{
switch(match){
case '<':
return '<'
case '>':
return '>'
case '"':
return '"'
case '&':
return '&'
}
})
}
module.exports={
htmlEscape,
htmlRecover
}