To keep "/", please add "\/"
If using alternate delimiters, there's no need to protect '/'.
$code =~ s/[^\/\w"':.;]//g;
BTW: this is a perhaps a job better suited for tr///d, except that it doesn't support \w and one would have to hardcode the ranges - and it may even be worse if unicode were involved, but the OP may like to know anyway.
In reply to Re^2: RegEx Character Class
by blazar
in thread RegEx Character Class
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |