UNPKG

itheima-szy-data

Version:

``` npm install itheima-szy-data ```

34 lines (32 loc) 809 B
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 } ;