in reply to RegEx Character Class

To keep "/", please add "\/"

$code =~ s/[^\/\w"':.;]//g;
will keep "/".

Cheers !

--VC



There are three sides to any argument.....
your side, my side and the right side.

Replies are listed 'Best First'.
Re^2: RegEx Character Class
by blazar (Canon) on Sep 12, 2007 at 09:13 UTC
    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.