UNPKG

itheima-tools-gdq

Version:

格式化时间,HTMLEscape的功能

36 lines (32 loc) 630 B
function htmlEscape(htmlStr){ return htmlStr.replace(/<|>|"|&/g,(match)=>{ switch(match){ case "<": return '&lt;' case ">": return '&gt;' case '"': return 'quto;' case '&': return '&amp;' } }) } function htmlUnEscape(htmlStr){ return htmlStr.replace(/&lt;|&gt;|quto;|&amp;/g,(match)=>{ switch(match){ case "&lt;": return '<' case "&gt;": return '>' case 'quto;': return '""' case '&amp;': return '&' } }) } module.exports ={ htmlEscape, htmlUnEscape }