微信小程序 去除富文本所有html标签
2021-08-30 本文已影响0人
安徒生1997
let text = i.detail.replace(/<(p|div)[^>]*>(<br\/?>| )<\/\1>/gi, '\n').replace(/<br\/?>/gi, '\n').replace(/<[^>/]+>/g, '').replace(/(\n)?<\/([^>]+)>/g, '').replace(/\u00a0/g, ' ').replace(/ /g, ' ').replace(/<\/?(img)[^>]*>/gi, '').replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/'/g,"\'").replace(/"/g,"\"").replace(/<\/?.+?>/g,"")