my $text = 'foo /* bar **/ baz /* ack! ph! */'; $text =~ s| \/\* # '/*', escaped [^\*]* # 0 or more non-'*' characters \*\/ # '*/', escaped ||x; print $text;