in reply to Strip bad characters from a string

s/(['"])/\\$1/g;

Replies are listed 'Best First'.
Re: Re: Strip bad characters from a string
by Anonymous Monk on Mar 19, 2004 at 01:57 UTC
    I have
    $a = "dfowusgfiwu42394353****hsdfsd"; print "$a\n"; $a =~ s/!([a-zA-Z0-9])//g; print "$a\n";
    what's not right? it doesn't do anything to the string... and I know it looks useless, but it's a test for something else. what I want is to delete any and all characters from a string that don't fit into [a-zA-Z0-9]... unless things like "$(@$&%*" are in there...