UNPKG

cyl-tools

Version:

提供格式化时间,html相关功能

38 lines (33 loc) 797 B
// 转义 html function htmlEscape(htmlstr){ return htmlstr.replace(/<|>|"|&/g, (match)=>{ switch (match) { case '<': return '&lt;' case '>': return '&gt;' case '"': return '&quot;' case '&': return '&amp;' } }) } function htmlUnEscape(htmlstr){ return htmlstr.replace(/&lt;|&gt;|&quot;|&amp;/g, (match)=>{ switch (match) { case '&lt;': return '<' case '&gt;': return '>' case '&quot;': return '"' case '&amp;': return '&' } }) } module.exports = { htmlEscape, htmlUnEscape }