in reply to Multi Line c comments
This should work for you. See Death to Dot Star! for details. Be careful on this one. It's really tricky.$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 */
With all due respect to kilinrax, his (her?) regex can fail under some circumstances:
This prints foo /* bar **/ baz. The extra asterisk at the end of the first C comment throws off the regex.my $text = 'foo /* bar **/ baz /* ack! ph! */'; $text =~ s| \/\* # '/*', escaped [^\*]* # 0 or more non-'*' characters \*\/ # '*/', escaped ||x; print $text;
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 |