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 = "//\"
In reply to Re: Removing '//' comments
by GrandFather
in thread Removing '//' comments
by Yunus
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |