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