in reply to Multi Line c comments

$text =~ s|/\* # First slash and star /* (?: # Non-backreferencing parentheses (?!\*/) # not a star slash */ . # ok to inch along )* # Zero or more \*/||sx; # Followed by a star slash */
This should work for you. See Death to Dot Star! for details. Be careful on this one. It's really tricky.

With all due respect to kilinrax, his (her?) regex can fail under some circumstances:

my $text = 'foo /* bar **/ baz /* ack! ph! */'; $text =~ s| \/\* # '/*', escaped [^\*]* # 0 or more non-'*' characters \*\/ # '*/', escaped ||x; print $text;
This prints foo /* bar **/ baz. The extra asterisk at the end of the first C comment throws off the regex.

Cheers,
Ovid

Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.

Replies are listed 'Best First'.
RE: (Ovid) RE: Multi Line c comments
by $code or die (Deacon) on Nov 15, 2000 at 23:51 UTC
    Ahh. This wasn't here when I started typing my reply. I think you said it better than me anyway :)