in reply to UNO DOS, HTML

Just grab the first comment;

$html = '<!--% xxxx UNO xxxx %--> <!--% xxxx DOS xxxx %-->'; $html =~ s/(<!--.*?-->\s*)<!--%(.*?) DOS (.*?)%-->/$1GONE/s; print $html;

Or make sure there is a comment beforehand:

$html = '<!--% xxxx UNO xxxx %--> <!--% xxxx DOS xxxx %-->'; $html =~ s/-->\s*<!--%(.*?) DOS (.*?)%-->/--> GONE/s; print $html;

There is probably a cleaner way to do this without capturing the first comment at all, or by using a g modifier, skipping the first comment and replacing the second.