lxyyy
Version:
提供了格式化时间HTMLEscape相关的功能
33 lines (32 loc) • 571 B
JavaScript
function htmlEscape(htmlStr) {
return htmlStr.replace(/<|>|"|&/g, function(match) {
switch (match) {
case '<':
return '<'
case '>':
return '>'
case '"':
return '&quto;'
case '&':
return '&'
}
})
}
function htmlUnEscape(htmlStr) {
return htmlStr.replace(/<|>|&quto;|&/g, function(match) {
switch (match) {
case '<':
return '<'
case '>':
return '>'
case '&quto;':
return '"'
case '&':
return '&'
}
})
}
module.exports = {
htmlEscape,
htmlUnEscape
}