undefinedfix
Sign in

Regular demand, ask you guys to come to harass?

jet_black82 edited in Wed, 25 Jan 2023

The length is 8-20 characters. There are at least three kinds of letters, numbers, uppercase and punctuation. Spaces and Chinese characters are not allowed

3 Replies
nxyff
commented on Wed, 25 Jan 2023

I don't think this is necessarily handled by a regular formula, at least not by a regular formula“ There are at least three kinds of letters, numbers, uppercase and punctuation marks. "In fact, the accurate description here is" there are at least three kinds of lowercase letters, numbers, uppercase and punctuation marks. "This is what regular expressions can't deal with simply. I have to deal with it

  1. A rule-based test to judge whether there are 8-20 characters and no spaces or Chinese characters
  2. Construct rules to judge whether there are lowercase letters, numbers, uppercase letters and punctuation marks respectively, and test the above strings. If each test passes, a counter (such as typecount, which is initialized as 0) will be added with 1. After four tests, if typecount > = 3, it meets the requirements. In this test, you can also give a prompt of type compliance in combination with the corresponding test rules.

This is generally used to set the password requirements.

DyedPurple
commented on Wed, 25 Jan 2023

Generally, there are at least one and at least three kinds of regularities

lnrek
commented on Thu, 26 Jan 2023

The requirements are not very clear, and a rule can not satisfy all the conditions at the same time, especially including at least three, which need to be judged separately. What's more, we should make it clear what punctuation marks mean. These words are too general.

if(val.test(/[A-z0-9\.\,\:\'\"\`\?\!]{8,20}/)&&val.test(/[A-z]/)&&val.test(/[0-9]/)&&val.test(/\.\,\:\'\"\`\?\!/)){};