Regular Expressions 101

Community Patterns

Match HTML comments with nested comments


Regular Expression
PCRE (PHP <7.3)



Even if this is not valid HTML, it's more to understand the concept of recursion in patterns.

It was an answer to a Stack overflow question:

The idea is to use PCRE's recursive pattern to solve the problem.

Submitted by Patrick Janser - a year ago