[英]Need this regular expression not to require at least 1 capital letter
The regular expression below is written now to require a capital letter. 现在编写下面的正则表达式以要求使用大写字母。 I was just told that capital letters are optional but not required.
有人告诉我,大写字母是可选的,但不是必需的。 How can I write this regular expression without changing any of the other parameters to not make at least one capital letter required.
如何在不更改任何其他参数的情况下编写此正则表达式,以使至少不需要一个大写字母。
/^(?:(?!([a-zA-Z0-9-().&@?""#,+''\s\/])\1\1)[a-zA-Z0-9-().&@?""#,+''\s\/]){7,}$/
That regular expression already does not require an upper-case character. 该正则表达式已经不需要大写字符了。 The only "interesting" things it insists on are that the string cannot start with the same thing repeated 3 times (the same character that is), and the overall string needs to be at least seven characters long.
它坚持的唯一“有趣”的事情是字符串不能以相同的事物重复3次(即相同的字符)开头,并且整个字符串至少需要七个字符长。
Also the doubling of single- and double-quote characters in the regex is not necessary. 同样,不需要在正则表达式中将单引号和双引号字符加倍。
There is nothing in that regex that requires uppercase letters. 该正则表达式中没有要求大写字母的内容。 The requirements imposed by that regex are:
该正则表达式施加的要求是:
-().&@?"#,+'
, whitespace, or /
. -().&@?"#,+'
,空格或/
。 If I'm not mistaken this appears to be used for password validation. 如果我没记错的话,这似乎用于密码验证。 This is a poor use of regexes for several reasons.
由于多种原因,这是对正则表达式的不良使用。
It's hard to read. 很难读。 What does the regex check, exactly?
正则表达式究竟检查什么? What does that big mess of characters actually do?
这么大的字符混乱实际上是做什么的? If you're not a regex expert it's gibberish.
如果您不是正则表达式专家,那简直就是胡言乱语。
It's got several requirements crammed into one big regex. 一个大的正则表达式中塞满了几个要求。 It would be easier to read and more maintainable if the checks were split into several lines of code:
如果将检查分成几行代码,将更易于阅读和维护。
if (password.length < 7) reject("Too short."); if (numRepeatedCharacters(password) >= 3) reject("Too repetitive."); if (numDigits(password) < 1) reject("Digit required."); if (numSymbols(password) < 1) reject("Symbol required."); // etc.
It contains a character whitelist instead of a blacklist. 它包含一个字符白名单而不是黑名单。 Please don't whitelist characters.
请不要将字符列入白名单。 There's no reason to prevent users from using characters you haven't thought of.
没有理由阻止用户使用您从未想到的字符。 What if they want to use an asterisk, percent sign, accented letters, etc.?
如果他们想使用星号,百分号,带重音的字母等怎么办? You will reject those characters for no good security reason.
您将出于安全原因拒绝这些字符。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.