in reply to Removing '//' comments

my first thought here was Regexp::Common::Comment ... Looking in its source, it basically does s#//[^\n]*$##s; It's interesting to note that it behaves in the same way as the regexp GrandFather demo'd above, especially with *str = "//\"//";

tye's example (though i had to make it s#foo#bar#xgm instead of s<foo><bar>xgm before it would compile) does work with GrandFather's test cases.
use warnings; use Regexp::Common qw /comment/; while(<DATA>){ my ($line, $simple, $RE, $tye) = ($_)x4; $simple =~ s#//[^\n]*$##s; $RE =~ s#$RE{comment}{Portia}#\n#; $tye =~ s# (^ (?: [^/'"]+ | '([^'\\]+|\\.)*' | "([^"\\]+|\\.)*" | (?<!/)/(?!/) )* ) //.* #$1#xgm; print " [DATA] $line"; print "[simple] $simple"; print " [RE] $RE"; print " [tye] $tye"; print "\n"; } __DATA__ blah // comment /* // */ /* */ *str = "//\"//";