Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
PCRE2 (PHP >=7.3)

/
<(?<tag>[^!\/>\s]+)((?:\s+((?<attrName>[^\/='"<>\s]+)(=(?<attrVal>('[^']*')|("[^"]*")|([^\s<>'"=`]+)))?)))*\s*\/?>
/
gm

Description

Regex pattern which matches HTML tag with its attributes.

Submitted by Bobkorinek - 2 years ago