regex - Regular expression for Password Requirements for PCI Compliance -
here password requirements pci compliance:
- must contain @ least 1 upper case letter
- must contain @ least 1 lower case letter
- must contain @ least 1 number
- must contain @ least 1 special character such #, !, ?, ^, or @.
please tell me how create such regulat expressions? can`t figure out how it
don't single regex. there's no need in single regex, , easier change rules, , easier read, if make multiple regex checks.
if doing in perl, example, you'd do
my $ok = ($pw =~ /[a-z]/) && # has @ least 1 lowercase char ($pw =~ /[a-z]/) && # has @ least 1 uppercase char ($pw =~ /\d/) && # has @ least 1 digit ($pw =~ /[#!?^@]); # has punctuation
that far easier read later on when have maintain code in future.
Comments
Post a Comment