if ($string =~ /[^a-z]/) { # if it contains even one character NOT in the range, it doesn't meet the criteria # do some error }