Regular Expressions 101

Community Library Entry

1

Regular Expression
PCRE (PHP <7.3)

/
<img(([^>]*)srcset\=(?:\"|\')([^\"\']*)(?:\"|\'))?([^>]*)src=(?:\"|\')([^\"\']*)(?:\"|\')(([^>]*)srcset\=(?:\"|\')([^\"\']*)(?:\"|\'))?([^>]+)*>
/
g

Description

Not depending on the src or srcset order, but some matches can be empty, depending on the img syntax.

Submitted by Geoffrey Crofte & Sébastien Decamme - 9 years ago