UNPKG

itkun-tools

Version:

提供了格式化时间,HtmlEscape相关的功能

35 lines (34 loc) 812 B
//定义转义HTMl字符的方法; function HtmlCape(HtmlStr){ return HtmlStr.replace(/<|>|"|&/g,(math)=>{ switch(match){ case '<': return '&lt;' case '>': return '&gt' case '"': return '&quot;' case '&' : return '&amp' } }) } //定义还原html的方法; function HtmlUnEs(str){ return str.replace(/&lt;|&gt;|&quot;|&amp;/g,(match)=>{ switch(match){ case '&lt;': return '<' case '&gt;': return '>' case '&quot;': return '"' case '&amp;': return '&' } }) } module.exports={ HtmlUnEs, HtmlCape }