Regular Expressions 101

Community Patterns

HTML tags and comments split

0

Regular Expression
ECMAScript (JavaScript)

/
(<(?!\/)[a-zA-Z\-0-9]+?(?:[\s]*?[a-zA-Z\-0-9]+?(?:=(?:"[\s\S]*?"|'[\s\S]*?')){0,1})*?[\s]*?\/{0,1}>)|(<\/[\S\s]+?>)|(<!--[\s\S]*?-->)
/
gmi

Description

This regex is used to split HTML tags and comments.

Submitted by Danilo Celestino de Castro - 7 years ago