Regular Expressions 101

Community Patterns

Remove / delete / strip style attribute from html tags

0

Regular Expression
PCRE (PHP <7.3)

/
\<(\w+)\s[^>]*?style=([\"|\']).*?\2\s?[^>]*?(\/?)>
/
gmi

Description

This one removes ALL attributes if "style" is found. See my other expression to only remove the style.

Submitted by socialblogsitewebdesign.com - 9 years ago