in reply to Pattern Matching
You can also negate a character class with the ^ symbol at the start:if ($string =~ /^[a-z]+$/) { # we have a string of at least one character of the range a-z }
That's probably your best bet. If you didn't mind A-Z as well, you could use \W, which matches non-word (\w) characters (which are A-Za-z0-9_). For more gritty details, see perlman:perlre.if ($string =~ /[^a-z]/) { # if it contains even one character NOT in the range, it doesn't m +eet the criteria # do some error }
|
|---|