in reply to Re^2: Removing XML comments with regex
in thread Removing XML comments with regex

You're right about the minimal match on .*?, but keep /s in there or it will miss multiline comments.
$xml =~ s/<!--.*?-->//sg;

Replies are listed 'Best First'.
Re^4: Removing XML comments with regex
by tuxz0r (Pilgrim) on Oct 24, 2007 at 19:41 UTC
    Right on,
    s/<!--.*?-->//gs
    is the proper way to go, since we don't want to be greedy and treat the beginning of the first comment until the end of the last comment as a giant comment itself.