Skip to main content


 

Symptoms


Pattern pour mot de passe
 

Diagnoses


Bonjour.

Serait-il possible de faire une pattern, ou une expression, qui me permettrai de valider qu'un mot de passe saisie dans une TEXTBOX contient au minimum 1 lettre minuscule, 1 lettre majuscule, 1 chiffre, 1 caractère spéciale et d'une taille minimum de 8 caractères ?

Merci.
 

Resolution

Dear Mr Jouanne,

ISSUE:

Would it be possible to make a pattern, or expression, which allow me to validate a password entry in a TEXTBOX contain at least 1 lowercase letter, 1 capital letter, 1 numeric, 1 special character and size minimum of 8 characters?

RESOLUTION:

During my first test I had some issue with my machine and found that we have a limit of 200 characters for the pattern expression. It's not a very important issue as generally the pattern is short.

After additional test, the following pattern works correctly as pattern and regular expression in the "Expression" of the label:

^(?=(.*(0-9]))(?=.*)@_$^*]{}-_ =|:>./?])(?=.*)a-z])(?=(.*(A-Z]))(?=(.*)).{8,16}$


In addition, you used an "Expression" on a label to display a warning if you don't have one of these characters : e"~)`(!and<*%',])
But you use (?=(.*("~)`(!and<*%',]))
As it's a check on only one expression, we advise to more use
<"~)`(!and<*%',]
?= is zero-width positive lookahead assertion is not necessary in this context.


Finally, you can use one pattern to do all your need:
- Match one numeric (?=(.*(0-9])) (?= is zero-width positive lookahead assertion)
- Match one special character (?=.* @_$^*]{}-_ =|:>./?]) (?= is zero-width positive lookahead assertion)
- Match on lower case (?=.* a-z]) (?= is zero-width positive lookahead assertion)
- Match one upper case (?=(.*(A-Z])) (?= is zero-width positive lookahead assertion)
- Have a length between 8 and 16 characters (?=(.*)).{8,16} (?= is zero-width positive lookahead assertion)
- Do not match some other characters (?!.* "~)`(!and<*%',]) (?! is zero-width negative lookahead assertion)

^(?=(.*(0-9]))(?=.*)@_$^*]{}-_ =|:>./?])(?=.*)a-z])(?=(.*(A-Z]))(?=(.*)).{8,16}(?!.*}"~)`(!and<*%',])$



For more information about zero-width positive lookahead assertion and zero-width negative lookahead assertion :

https://msdn.microsoft.com/fr-fr/library/bs2twtah(v=vs.110).aspx
http://stormimon.developpez.com/dotnet/expressions-regulieres/
http://g-rossolini.developpez.com/tutoriels/php/regex/?page=syntaxe


You have 2 days to accept or reject this resolution. If you feel the issue is not resolved, please reject this resolution.
Otherwise, please take the opportunity to submit feedback, using the link included in this message.

Thanks, and regards
Olivier Chatagnon




 
Be the first to reply!

Reply