in reply to Password Regex extended
Original Post:
Other than the warning (sorry for the line-wrap munging on this), the following approach seems to work. Except for explicitly suppressing the warning, can anyone think of a way to make this work 'quietly'?
>perl -wMstrict -le "my $min_10 = qr{ (?= .{10}) }xms; my $a_digit = qr{ (?= .* \d) }xms; my $a_lower = qr{ (?= .* [[:lower:]]) }xms; my $an_upper = qr{ (?= .* [[:upper:]]) }xms; my $special = qr{ [@\#\$%^&+=] }xms; my $a_spec = qr{ (?= .* $special) }xms; my $valid = qr{ \A $min_10 (?: $a_digit $a_lower $an_upper $a_spec){3,} }xms; while (chomp(my $pw = <STDIN>)) { my $ok = $pw =~ $valid; print qq{'$pw' }, $ok ? 'valid' : 'INVALID'; } " (?: (?msx-i: (?= .* \d) ) (?msx-i: (?= .* [[:lower:]]) ) (?ms +x-i: (?= . * [[:upper:]]) ) (?msx-i: (?= .* (?msx-i: [@\#\$%^&+=] )) )) +{3,} matches null string many times in regex; marked by + <-- HERE in m/ + \A (?msx -i: (?= .{10}) ) (?: (?msx-i: (?= .* \d) ) (?msx-i: +(?= .* [[: lower:]]) ) (?msx-i: (?= .* [[:upper:]]) ) (?msx-i: (?= .* (?msx-i: [@ +\#\$%^&+=] )) )){3,} <-- HERE / at -e line 1. '' INVALID ' ' INVALID x 'x' INVALID xxxxxxxxx 'xxxxxxxxx' INVALID xxxxxxxxxx 'xxxxxxxxxx' INVALID %Aa123456 '%Aa123456' INVALID %Aa1234567 '%Aa1234567' valid 1aA%23456 '1aA%23456' INVALID 1aA%234567 '1aA%234567' valid Terminating on signal SIGINT(2)
|
|---|