RegEx Get the mime-type from a Base64

Posted on May 3, 2020

Quite simple but I had to do a bit of trial and error:

let yourImage = 'data:image/jpeg;base64,hghSTHGSVHBj...'
let reg = new RegExp(/data:(.*);base64/gi)
let mime = reg.exec(s)[1]