简体   繁体   English

需要“至少两个”某些字符的密码正则表达式

[英]Password regex that requires “at least two of” certain characters

Im working on javascript regex which includes having following conditions.我正在研究 javascript 正则表达式,其中包括具有以下条件。 So far with no luck.到目前为止没有运气。

-The minimum character count allowed is 8. - 允许的最小字符数为 8。

-The maximum character count allowed is 64. - 允许的最大字符数为 64。

-The entered text should include at least two of the following - numbers, lowercase letters, uppercase letters, Special characters. - 输入的文本应至少包含以下两项 - 数字、小写字母、大写字母、特殊字符。

-Entering symbols will not be supported. - 不支持输入符号。

So far what I have is this @anubhava answer here .到目前为止,我有什么是这个@anubhava答案在这里

^(?=.*?[AZ])(?=.*?[az])(?=.*?[0-9])(?=.*?[#?!@$%^&*-]).{8,63}$

This regex will enforce these rules:此正则表达式将强制执行以下规则:

-At least one upper case English letter, (?=.*?[AZ]) - 至少一个大写英文字母,(?=.*?[AZ])

-At least one lower case English letter, (?=.*?[az]) -至少一个小写英文字母,(?=.*?[az])

-At least one digit, (?=.*?[0-9]) - 至少一位,(?=.*?[0-9])

-At least one special character, (?=. ?[#?!@$%^& -]) - 至少一个特殊字符,(?=. ?[#?!@$%^& -])

-Minimum eight in length .{8,63} (with the anchors) - 长度至少为 8 .{8,63}(带锚点)

My Question is how do I satify my 3rd and 4th conditions Which is :-我的问题是如何满足我的第三个和第四个条件,即:-

-The entered text should include at least two of the following - numbers, lowercase letters, uppercase letters, Special characters. - 输入的文本应至少包含以下两项 - 数字、小写字母、大写字母、特殊字符。

-Entering symbols will not be supported. - 不支持输入符号。

Any help would be appreciated.任何帮助,将不胜感激。

 var regex =/^(?=.*\\d)(?=.*[!@#$%^&*])(?=.*[az])(?=.*[AZ]).{8,64}$/; function test() { if(regex.test(document.getElementById("txtPassword").value)===false) { alert("Min 8,Max 64,At Least One Uppercase Character,One Lowercase Character,One Numeric Value And One Special Character(!@#$%^&*) Required "); } else { alert("Success"); } }
 <input type="text" id="txtPassword" /> <button id="testBtn" onclick=test()>CheckPassword</button>

^(?!.*[^A-Za-z0-9#?!@$%^&*-]$)(?![a-z]*$)(?![A-Z]*$)(?![0-9]*$)(?![#?!@$%^&*-]*$).{8,64}$

The string should not contain any symbol outside the 4 groups of characters字符串不应包含 4 组字符之外的任何符号

^(?!.*[^A-Za-z0-9#?!@$%^&*-]$)

The string should not consist only of lower letters字符串不应只包含小写字母

(?![a-z]*$)

The string should not consist only of upper letters字符串不应仅由大写字母组成

(?![A-Z]*$)

The string should not consist only of digits字符串不应仅由数字组成

(?![0-9]*$)

The string should not consist only of special characters字符串不应仅包含特殊字符

(?![#?!@$%^&*-]*$)

The string should consist of 8 to 64 characters字符串应包含 8 到 64 个字符

.{8,64}$

UPDATED 2020-09-07更新 2020-09-07

If the string should contain symbols of at list 3 groups of 4如果字符串应该包含在列表 3 组 4 的符号

^(?!.*[^A-Za-z0-9#?!@$%^&*-]$)((?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])|(?=.*[a-z])(?=.*[A-Z])(?=.*[#?!@$%^&*-])|(?=.*[a-z])(?=.*[0-9])(?=.*[#?!@$%^&*-])|(?=.*[A-Z])(?=.*[0-9])(?=.*[#?!@$%^&*-])).{8,64}$

The string should not contain any symbol outside the 4 groups of characters字符串不应包含 4 组字符之外的任何符号

^(?!.*[^A-Za-z0-9#?!@$%^&*-]$)

Then 4 variants of 3 groups of 4 that the symbols should be member of:然后是符号应该是成员的 3 组 4 组的 4 个变体:

(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])

or或者

(?=.*[a-z])(?=.*[A-Z])(?=.*[#?!@$%^&*-])

or或者

(?=.*[a-z])(?=.*[0-9])(?=.*[#?!@$%^&*-])

or或者

(?=.*[A-Z])(?=.*[0-9])(?=.*[#?!@$%^&*-])

and finally the string should consist of 8 to 64 characters最后字符串应该由 8 到 64 个字符组成

.{8,64}$

Text includes at least two of the following - numbers, lowercase letters, uppercase letters, Special characters.文本至少包括以下两项- 数字、小写字母、大写字母、特殊字符。 No characters outside [A-Za-z0-9#?!@$%^&*-] [A-Za-z0-9#?!@$%^&*-] 之外没有字符

^(?=.*?[A-Z])(?=.*?[a-z])(?!.*?[^A-Za-z0-9#?!@$%^&*-]).{8,63}$|^(?=.*?[A-Z])(?=.*?[0-9])(?!.*?[^A-Za-z0-9#?!@$%^&*-]).{8,63}$|^(?=.*?[A-Z])(?=.*?[#?!@$%^&*-])(?!.*?[^A-Za-z0-9#?!@$%^&*-]).{8,63}$|^(?=.*?[a-z])(?=.*?[0-9])(?!.*?[^A-Za-z0-9#?!@$%^&*-]).{8,63}$|^(?=.*?[a-z])(?=.*?[#?!@$%^&*-])(?!.*?[^A-Za-z0-9#?!@$%^&*-]).{8,63}$|^(?=.*?[0-9])(?=.*?[#?!@$%^&*-])(?!.*?[^A-Za-z0-9#?!@$%^&*-]).{8,63}$

Text includes at least three of the following - numbers, lowercase letters, uppercase letters, Special characters.文本至少包括以下三个- 数字、小写字母、大写字母、特殊字符。 No characters outside [A-Za-z0-9#?!@$%^&*-] [A-Za-z0-9#?!@$%^&*-] 之外没有字符

^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?!.*?[^A-Za-z0-9#?!@$%^&*-]).{8,63}$|^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[#?!@$%^&*-])(?!.*?[^A-Za-z0-9#?!@$%^&*-]).{8,63}$|^(?=.*?[A-Z])(?=.*?[0-9])(?=.*?[#?!@$%^&*-])(?!.*?[^A-Za-z0-9#?!@$%^&*-]).{8,63}$|^(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$%^&*-])(?!.*?[^A-Za-z0-9#?!@$%^&*-]).{8,63}$

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 密码验证正则表达式:要求和禁止某些字符 - Password validation regex: require and forbid certain characters 密码的正则表达式必须至少包含八个字符,至少一个数字以及大小写字母和特殊字符 - Regex for password must contain at least eight characters, at least one number and both lower and uppercase letters and special characters 密码包含至少6个字符,1个数字,1个字母和任何特殊字符的JavaScript正则表达式 - JavaScript regex for password containing at least 6 characters, 1 number, 1 letter, any special characters 最少 6 个字符的密码 REGEX,至少一个字母和一个数字,可以包含特殊字符 - Password REGEX with min 6 chars, at least one letter and one number and may contain special characters 正则表达式将强密码与两个或多个特殊字符匹配 - Regex match a strong password with two or more special characters 正则表达式包含某些字符和两个词(对与错) - Regex to include certain characters and two words (true and false) 允许RegEx中的某些字符 - Tolerate certain characters in RegEx 正则表达式为字母数字密码,至少包含1个数字和字符 - Regex for alphanumeric password, with at least 1 number and character 密码应至少包含 1 位数字 - ValidateJS 中的正则表达式 - Password should contain at least 1 digit - Regex in ValidateJS 正则表达式,删除重复出现的字符,但至少保留一个 - Regex, removing recurring characters but keeping at least one
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM