3
I need to validate the criteria in a password:
- It must contain at least one capital letter.
- At least one tiny
- At least one number
- The size should be between 6 and 32 characters
- May not have any special character or space
- It should have all 3 types: uppercase, lowercase and numbers, no matter the order
I tried several ways, I took a look at the documentation of regex (Elixir and Perl), but I stuck here:
Regex.run(~r/^[A-Z](?=.*)[a-z](?=.*)[^\W_]{5,30}$/,IO.gets"")
But this regex only allows the password starting with uppercase and does not allow numbers if I add something like \d(?=.*)
or [0-9](?=.*)
nothing else works.
As an example in ES/JS it would be: /^(?=.*[A-Z])(?=.*[a-z])(?=.*\d)[^\W_]{6,32}$/
This example in Js is correct. This is a question or an answer?
– BrTkCa
The example in JS is correct, works for all criteria and independent of the order of the items. It is a question, fix the title.
– João Paulo