Use regexes with char classes:
#!/usr/bin/perl use warnings; use strict; my $allowed = "pure"; my $re = quotemeta $allowed; my $str = "p u+r-e"; $str =~ s/[^$re]//g; print $str, "\n";
In reply to Re: Scurbbing a string
by moritz
in thread Scrubbing a string
by princepawn
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |