Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
Created·2016-04-14 06:35
Flavor·JavaScript

/
<([a-z][a-z0-9]*)(?:[^>]*?((?:\s(?:src|href|style)=['\"][^'\"]*['\"]){0,3}))[^>]*?(\/?)>
/
ig
Open regex in editor

Description

This regex keeps multiple attributes of given HTML tag. Given that required attributes are consective (in any order) and following the tag name.

Submitted by Ahmad Ahsan