var base64Data = 'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQ'
var base64ImageContent = base64Data.replace(/^data:image\/(png|jpg);base64,/, "");
console.log(base64ImageContent) <-- still the same
这里有什么问题?替换在这里不起作用,我的错误在哪里?
答案 0 :(得分:0)
您已经:
var base64Data ='data:image / jpeg ; base64,/ 9j / 4AAQSkZJRgABAQ'
但你匹配:
var base64ImageContent = base64Data.replace(/ ^ data:image /(png | jpg ); base64,/,“”);
您需要加入jpeg
:
var base64ImageContent = base64Data.replace(/^data:image\/(png|jpg|jpeg);base64,/, "");