UNPKG

zll-tools

Version:

这是一个格式化时间,和还原html特殊字符的包

35 lines (33 loc) 786 B
// 转意html的方法 function htmlEscape(htmlStr){ return htmlStr.replace(/<|>|"|&/g,math=>{ switch(math){ case '<': return '&lt;' case '>': return '&gt;' case '"': return '&quot;' case '&': return '&amp;' } }) } function htmlUnEscape(str){ return str.replace(/&lt;|&gt;|&aquet;|&amp;/g,(math)=>{ switch(math){ case '&lt;': return '<' case '&gt;': return '>' case '&aquet;' : return '"' case '&amp;' : return '&' } }) } module.exports = { htmlEscape, htmlUnEscape }