Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
PCRE (PHP <7.3)

/
(\s+)(\S+)=["']?((?:.(?!["']?\s+(?:\S+)=|[>"']))+.)["']?
/
g

Description

This regex will find all attributes, values, and the equal operator, as well as the white space between attributes. You can use this to extract all attributes to remove all inline styles.

Submitted by Demetri Ojeda - 9 years ago