声明:本站文章均为作者个人原创,图片均为实际截图。如有需要请收藏网站,禁止转载,谢谢配合!!!

1、remove the tag of html

testString.replace(/<[^>]+>/g, '')

2、replace the tag of br [<br/>] with \n

testString.replace(/(\<br \/\>)/g, '\n')

3、find the img

const matchReg = /<img.*?(?:>|\/>)/gi
const result = data.match(matchReg)
const imageArr = []
if (result !== null && result.length > 0) {
    result.map((item, index) => {
        const src = item.match(/src=[\'\"]?([^\'\"]*)[\'\"]?/i)
        data = data.replace(item, '\n【picture' + (index + 1) + '】\n') // replace the img with some text like image xxx, usually used like rich-text in excel
        imageArr.push(src[1])
    })
}



点赞(0) 打赏

Comment list 共有 0 条评论

暂无评论