try the following:
/[a-zA-Z]/
or
/[[:alpha:]]/
Otherwise, you should give examples of the strings you want to match.
also read perldoc perlrequick
Edit: @OP, you provided an example string, but I'm not quite sure what you want to do with it. so I suppose you want to check if all letters, all numbers, or something else. here's where to start. Everything from perldoc perlrequick (and perlretut), so please read them.
sub check{
my $str = shift;
if ($str =~ /^[a-zA-Z]+$/){
return $str." all letters";
}
if ($str =~ /^[0-9]+$/){
return $str." all numbers";
}else{
return $str." a mix of numbers/letters/others";
}
}
$string = "99932";
print check ($string)."\n";
$string = "abcXXX";
print check ($string)."\n";
$string = "9abd99_32";
print check ($string)."\n";
Exit
$ perl perl.pl
99932 all numbers
abcXXX all letters
9abd99_32 a mix of numbers/letters/others
source
share