lys-tools-a
Version:
提供了格式化事件,HTMLEscape 功能
33 lines (30 loc) • 799 B
JavaScript
function htmlEscape(htmlStr) {
return htmlStr.replace(/<|>|"|&/g, function (match) {
if (match === '<') {
return '<'
} else if (match === '>') {
return '>'
} else if (match === '"') {
return '"'
} else if(match === '&'){
return '&'
}
})
}
function htmlUnEscape(str) {
return str.replace(/<|>|"|&/g, function (match) {
if (match === '<') {
return '<'
} else if (match === '>') {
return '>'
} else if (match === '"') {
return '"'
} else if (match === '&') {
return '&'
}
})
}
module.exports = {
htmlEscape,
htmlUnEscape
}