itkun-tools
Version:
提供了格式化时间,HtmlEscape相关的功能
35 lines (34 loc) • 812 B
JavaScript
//定义转义HTMl字符的方法;
function HtmlCape(HtmlStr){
return HtmlStr.replace(/<|>|"|&/g,(math)=>{
switch(match){
case '<':
return '<'
case '>':
return '>'
case '"':
return '"'
case '&' :
return '&'
}
})
}
//定义还原html的方法;
function HtmlUnEs(str){
return str.replace(/<|>|"|&/g,(match)=>{
switch(match){
case '<':
return '<'
case '>':
return '>'
case '"':
return '"'
case '&':
return '&'
}
})
}
module.exports={
HtmlUnEs,
HtmlCape
}