in reply to Proper use of //x

Here's an efficient way to properly match HTML comments in a string of text. I use the "unrolling the loop" technique, and thus the commenting ability is helpful.
$COMMENT_rex = qr{ <!-- # opening <!-- [^-]* # 0 or more non hyphens (?: (?! -- \s* > ) # as long as it's NOT a --> - # - (?: - # - [^-]* # 0 or more non - (?: - [^-]+ )* # -, 1 or more non -, 0 or more times )? # optionally... [^-]* # 0 or more non - )* # 0 or more times -- \s* > # the ending --> }x;
The regex itself is complex, because the element it's matching is complex. Here's the unadulterated regex:
$COMMENT_rex = qr{<!--[^-]*(?:(?!--\s*>)-(?:-[^-]*(?:-[^-]+)*)?[^-]*)*--\s*>};
Ick.

japhy -- Perl and Regex Hacker