I want a script to select a username. The rules for selecting a username are:
I have tried this:
if (( length $passwd[$i]<=10 && length $passwd[$i]>=5 && $passwd[$i] =~ /.*\p{Lu}/ && $passwd[$i] =~ tr/0-9//cd && $passwd[$i] =~ /[a-z]/ ))
{
print "PASS\n";
}
else
{
print "FAIL\n";
}
As one perl regular expression, that could be:
if ($username =~ qr{^(?=.*[A-Z])(?=.*\d)(?=.*[@#*=])(?!.* ).{5,10}$}s) ...
Or:
if ($username =~ qr{^(?=.*[A-Z])(?=.*\d)(?=.*[@#*=])[^ ]{5,10}$}s)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With