Regular Expressions 101

Community Patterns

Match regex of width inside img

1

Regular Expression
PCRE (PHP <7.3)

/
(<\/?img.*[^-]width\s?[:|=]\s?['|"]?)[0-9]+px(.*)>
/

Description

Match regex of width inside img, can be used to find width whether it is inside style or not. Only find the first occurence of every img tag Already excluded min/max width

Submitted by anonymous - 4 years ago