| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- export function unescape(html) {
- return html
- .replace(html ? /&(?!#?\w+;)/g : /&/g, '')
- .replace(/</g, "<")
- .replace(/>/g, ">")
- .replace(/"/g, "\"")
- .replace(/'/g, "\'")
- .replace(/nbsp;/g,"\u00a0")
- .replace(/&/g,"")
- }
- /**
- * 反转义html
- * @param html
- * @returns {*}
- */
- export function unescapeHtml(html) {
- if(!html) return html;
- return html
- .replace(html ? /&(?!#?\w+;)/g : /&/g, '')
- .replace(/</g, "<")
- .replace(/>/g, ">")
- .replace(/"/g, "\"")
- .replace(/'/g, "\'")
- .replace(/nbsp;/g,"\u00a0")
- .replace(/&/g,"")
- }
- /**
- * 转义html
- * @param html
- * @returns {*}
- */
- export function escapeHtml(html) {
- if(!html) return html;
- return html
- .replace(/&/g, '&')
- .replace(/</g, '<')
- .replace(/"/g, '"')
- .replace(/'/g, "'")
- .replace(/>/g, '>')
- .replace(/\u00a0/g,"nbsp;")
- }
|