in reply to Removing '//' comments
Some interesting cases:
use warnings; use strict; while (<DATA>) { s/( (?:(?:[^\/][^\/]*?|)*? # anything, except comment sym +bol ("|').*?\2 # quoted string (and take ever +ything) (?:[^\/][^\/]*?|)*? # anything, except comment sym +bol )*? ) (?: \/\/ # comment symbol [^\\]* # anything, except continuatio +n )??$ /$1/x; print; } __DATA__ /* // */ /* */ *str = "//\"//";
Prints:
/* */ /* */ *str = "//\"
|
|---|