Regular Expressions 101

Community Patterns

Match HTML Tags

1

Regular Expression
PCRE (PHP <7.3)

/
<\/?(\w+)((\s+\w+(\s*=\s*(?:".*?"|'.*?'|[\^'">\s]+))?)+\s*|\s*)\/?>
/
gm

Description

Based on an expression from haacked.com

Submitted by anonymous - 4 years ago