Regular expression – delete comments using Perl

Is there any regular expression that can remove all comments in a given C program // and / ** / var from perl?

Given a multi-line program, it should use regular expressions to remove comments and return the uncommented parts.

Thank you.

Try Regexp::Common::comment:

< /p>

use Regexp::Common qw /comment/;
while (<>) {
s/($RE{comment}{C++})//;
}

Is there any regular expression that can remove all comments in a given C program // and / ** / var from perl?

Given a multi-line program, it should use regular expressions to remove comments and return the uncommented parts.

Thank you.

Try Regexp::Common::comment:

use Regexp::Common qw /comment/;
while (<>) {
s/($RE{comment}{C++})//;
}

< /p>

Leave a Comment

Your email address will not be published.