UNPKG

zxytools

Version:

``` npm install it-tools

35 lines (33 loc) 804 B
//定义转移html字符的函数 function htmlscape(htmlstr) { return htmlstr.replace(/<|>|"|&/g, math => { switch (math) { case '<': return '&lg;' case '>': return '&lt;' case '"': return '&quot;' case '&': return '&amp;' } }) } function htmlUnscape(htmlstr) { return htmlstr.replace(/&lt;|&lg;|&quot;|&amp;/g, math => { switch (math) { case '&lg;': return '<' case '&lt;': return '>' case '&quot;': return '"' case '&amp;': return '&' } }) } module.exports = { htmlscape, htmlUnscape }