Regular Expressions 101

Community Library

Community Library Entry

1

Regular ExpressionOpen Workspace

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

Description
Created·2016-04-14 06:35
Type·Substitution
Flavor·JavaScript

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
Open Workspace