^data:((?:\w+\/(?:(?!;).)+)?)((?:;[\w\W]*?[^;])*),(.+)$
test this pattern on regexr: https://regexr.com/4inht
regex pattern to match RFC 2397 data URL
dataurl := "data:" [ mediatype ] [ ";base64" ] "," data mediatype := [ type "/" subtype ] *( ";" parameter ) data := *urlchar parameter := attribute "=" value
data:image/jpeg;base64,UEsDBBQAAAAI
data:image/jpeg;key=value;base64,UEsDBBQAAAAI
data:image/jpeg;key=value,UEsDBBQAAAAI
data:;base64;sdfgsdfgsdfasdfa=s,UEsDBBQAAAAI
data:,UEsDBBQAAAAI
I suppose the browser fixes it, but tools like this one seem to reject it...
https://bit.dev/chriso/validator-js/is-data-uri
Are characters [;=,] valid for the data part of a data uri ?