参考:https://www.cnblogs.com/moqiutao/p/15629810.html
// html编码解码 export function htmlEncodeByRegExp(str) { var s = ''; if (str.length === 0) { return ''; } s = str.replace(/&/g, '&'); s = s.replace(/</g, '<'); s = s.replace(/>/g, '>'); s = s.replace(/ /g, ' '); s = s.replace(/\'/g, '''); s = s.replace(/\"/g, '"'); return s; } // 4.使用正则实现html解码 export function htmlDecodeByRegExp(str) { var s = ''; if (str.length === 0) { return ''; } s = str.replace(/&/g, '&'); s = s.replace(/</g, '<'); s = s.replace(/>/g, '>'); s = s.replace(/ /g, ' '); s = s.replace(/'/g, '\''); s = s.replace(/"/g, '\"'); return s; }
标签:return,htmlEncode,replace,正则,html,export,str,js,htmlDecode From: https://www.cnblogs.com/jqynr/p/17169139.html