Regular Expressions 101

Community Library Entry

0

Regular Expression
ECMAScript (JavaScript)

/
data:image\/[bmp,gif,ico,jpg,png,svg,webp,x\-icon,svg+xml]+;base64,[a-zA-Z0-9,+,/]+={0,2}
/
gm

Description

The expression is intended for finding one or more embedded Base64 Data URI in an HTML document. It will not find matches for any HTML surrounding the encoded Data URI match (<img> tag or src attributes), just the encoded data and MIME header, all that's needed to decode.

The MIME type is for images in this expression, but changing it to any other is as simple as replacing image in data:image, as well as adding or replacing any sub-types in the list immediately following that: [bmp,gif,ico,jpg,png,svg,webp,x-icon,svg+xml]

/$&\r\r/ used in the List function will format matches into a list

Submitted by Attention Deficit Hyperactivity Disorder - 2 years ago (Last modified 2 years ago)