PCI合规性密码要求的正则表达式 [英] Regular expression for Password Requirements for PCI Compliance

查看:99
本文介绍了PCI合规性密码要求的正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是 PCI 合规性的密码要求:

Here are password requirements for PCI compliance:

  • 必须至少包含一个大写字母
  • 必须至少包含一个小写字母
  • 必须至少包含一个数字
  • 必须至少包含一个特殊字符,例如#、!、?、^ 或@.

请告诉我如何创建这样的规则表达式?我不知道该怎么做

Please tell me how to create such regulat expressions? I can`t figure out how to do it

推荐答案

不要把它当作一个单一的正则表达式.不需要在单个正则表达式中进行,如果您只是进行多个正则表达式检查,更改规则会更容易,并且更容易阅读.

Don't do it as a single regex. There's no need to do it in a single regex, and it will be easier to change the rules, and be much easier to read, if you just make multiple regex checks.

例如,如果您在 Perl 中执行此操作,则只需执行

If you were doing this in Perl, for example, you'd just do

my $ok =
    ($pw =~ /[a-z]/) &&  # Has at least one lowercase char
    ($pw =~ /[A-Z]/) &&  # Has at least one uppercase char
    ($pw =~ /\d/)    &&  # Has at least one digit
    ($pw =~ /[#!?^@]);   # Has punctuation

当您以后必须维护代码时,这会更容易阅读.

That is far easier to read later on when you have to maintain the code in the future.

这篇关于PCI合规性密码要求的正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆