/^[^A-Za-z\-\ ]+$/ will only match if the string contains only bad characters.
sub validate_text { my ($text) = @_; if ($text =~ s/[^A-Za-z0-9 -]+//g) { print "Funny business fixed\n"; } else { print "Text was already clean\n"; } return $text; } my $validated = validate_text($test1);
In reply to Re: Inverse regexes for input validation
by ikegami
in thread Inverse regexes for input validation
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |