Can anyone get me with the regular expression to strip multiline comments and single line comments in a file?
eg:
\" WHOLE
Including tests:
use strict;
use warnings;
use Test::More qw(no_plan);
sub strip_comments {
my $string=shift;
$string =~ s#/\*.*?\*/##sg; #strip multiline C comments
return $string;
}
is(strip_comments('a/* comment1 */ code /* comment2 */b'),'a code b');
is(strip_comments('a/* comment1 /* comment2 */b'),'ab');
is(strip_comments("a/* comment1\n\ncomment */ code /* comment2 */b"),'a code b');