m[^(?=.*[a-zA-Z])[\w]+$] and print "$_ : ok" for qw[ 123 123_ 123_a a_ a_123 abc _ a123]; 123_a : ok a_ : ok a_123 : ok abc : ok a123 : ok