<tfoot id='C4YuL'></tfoot>

        • <bdo id='C4YuL'></bdo><ul id='C4YuL'></ul>

        <small id='C4YuL'></small><noframes id='C4YuL'>

      1. <i id='C4YuL'><tr id='C4YuL'><dt id='C4YuL'><q id='C4YuL'><span id='C4YuL'><b id='C4YuL'><form id='C4YuL'><ins id='C4YuL'></ins><ul id='C4YuL'></ul><sub id='C4YuL'></sub></form><legend id='C4YuL'></legend><bdo id='C4YuL'><pre id='C4YuL'><center id='C4YuL'></center></pre></bdo></b><th id='C4YuL'></th></span></q></dt></tr></i><div id='C4YuL'><tfoot id='C4YuL'></tfoot><dl id='C4YuL'><fieldset id='C4YuL'></fieldset></dl></div>
        <legend id='C4YuL'><style id='C4YuL'><dir id='C4YuL'><q id='C4YuL'></q></dir></style></legend>

      2. 用于检查 4 个不同字符组中的至少 3 个的正则表达式

        Regex for checking that at least 3 of 4 different character groups exist(用于检查 4 个不同字符组中的至少 3 个的正则表达式)

        1. <legend id='dOJrW'><style id='dOJrW'><dir id='dOJrW'><q id='dOJrW'></q></dir></style></legend>

          <tfoot id='dOJrW'></tfoot>
                <i id='dOJrW'><tr id='dOJrW'><dt id='dOJrW'><q id='dOJrW'><span id='dOJrW'><b id='dOJrW'><form id='dOJrW'><ins id='dOJrW'></ins><ul id='dOJrW'></ul><sub id='dOJrW'></sub></form><legend id='dOJrW'></legend><bdo id='dOJrW'><pre id='dOJrW'><center id='dOJrW'></center></pre></bdo></b><th id='dOJrW'></th></span></q></dt></tr></i><div id='dOJrW'><tfoot id='dOJrW'></tfoot><dl id='dOJrW'><fieldset id='dOJrW'></fieldset></dl></div>
                  <bdo id='dOJrW'></bdo><ul id='dOJrW'></ul>

                  <small id='dOJrW'></small><noframes id='dOJrW'>

                    <tbody id='dOJrW'></tbody>
                  本文介绍了用于检查 4 个不同字符组中的至少 3 个的正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试编写密码验证器.

                  I'm trying to write a password validator.

                  如何查看我提供的字符串是否包含至少 3 个不同的字符组?

                  How can I see if my supplied string contains at least 3 different character groups?

                  检查它们是否存在很容易——但至少有 3 个?

                  It's easy enough to check if they are existant or not ---but at least 3?

                  • 至少八 (8) 个字符

                  • at least eight (8) characters

                  至少三个不同的字符组

                  大写字母

                  小写字母

                  数字

                  特殊字符 !@#$%&/=?_.,:;-

                  special characters !@#$%&/=?_.,:;-

                  (我正在使用 javascript 进行正则表达式)

                  (I'm using javascript for regex)

                  推荐答案

                  只是为了学习 - 这种要求是否可以在纯正则表达式中实现?

                  Just to learn - would this kind of requirement be possible to implement in pure regex?

                  这将使它成为一个相当难以阅读(并因此维护!)的解决方案,但它是:

                  That'd make it a rather hard to read (and therefor maintain!) solution, but here it is:

                  (?mx)
                  ^
                  (
                    (?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])                # must contain a-z, A-Z and 0-9
                    |                                                # OR
                    (?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%&/=?_.,:;\-]) # must contain a-z, A-Z and special
                    |                                                # OR
                    (?=.*[a-z])(?=.*[0-9])(?=.*[!@#$%&/=?_.,:;\-]) # must contain a-z, 0-9 and special
                    |                                                # OR
                    (?=.*[A-Z])(?=.*[0-9])(?=.*[!@#$%&/=?_.,:;\-]) # must contain A-Z, 0-9 and special
                  )
                  .{8,}                                              # at least 8 chars
                  $
                  

                  一个(可怕的)Javascript 演示:

                  A (horrible) Javascript demo:

                  var pw = "aa$aa1aa";
                  if(pw.match(/^((?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])|(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%&/=?_.,:;\-])|(?=.*[a-z])(?=.*[0-9])(?=.*[!@#$%&/=?_.,:;\-])|(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#$%&/=?_.,:;\-])).{8,}$/)) {
                    print('Okay!');
                  } else {
                    print('Fail...');
                  }
                  

                  打印:Okay!,正如您在 Ideone 上看到的那样.

                  prints: Okay!, as you can see on Ideone.

                  这篇关于用于检查 4 个不同字符组中的至少 3 个的正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Toggle HTML radio button by clicking its label(通过单击标签来切换 HTML 单选按钮)
                  Javascript how to change radio button label text?(Javascript如何更改单选按钮标签文本?)
                  JavaScript radio button confirmation(JavaScript 单选按钮确认)
                  How can I automatically select specific radio buttons with Greasemonkey?(如何使用 Greasemonkey 自动选择特定的单选按钮?)
                  AngularJs. Is it possible to deselect HTML “radio” input by click?(AngularJs.是否可以通过单击取消选择 HTML“收音机输入?)
                  Checking Value of Radio Button Group via JavaScript?(通过 JavaScript 检查单选按钮组的值?)
                • <i id='L5J21'><tr id='L5J21'><dt id='L5J21'><q id='L5J21'><span id='L5J21'><b id='L5J21'><form id='L5J21'><ins id='L5J21'></ins><ul id='L5J21'></ul><sub id='L5J21'></sub></form><legend id='L5J21'></legend><bdo id='L5J21'><pre id='L5J21'><center id='L5J21'></center></pre></bdo></b><th id='L5J21'></th></span></q></dt></tr></i><div id='L5J21'><tfoot id='L5J21'></tfoot><dl id='L5J21'><fieldset id='L5J21'></fieldset></dl></div>
                    <bdo id='L5J21'></bdo><ul id='L5J21'></ul>
                  • <legend id='L5J21'><style id='L5J21'><dir id='L5J21'><q id='L5J21'></q></dir></style></legend>

                    <small id='L5J21'></small><noframes id='L5J21'>

                        <tbody id='L5J21'></tbody>

                        1. <tfoot id='L5J21'></tfoot>