1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| $regexMdp = '/^';
if ( $policy->nombreMinuscules > 0 )
$regexMdp .= '(?=(?:[^a-z]*[a-z]){' . $policy->nombreMinuscules . '})';
if ( $policy->nombreMajuscules > 0 )
$regexMdp .= '(?=(?:[^A-Z]*[A-Z]){' . $policy->nombreMajuscules . '})';
if ( $policy->nombreChiffres > 0 )
$regexMdp .= '(?=(?:[^0-9]*[0-9]){' . $policy->nombreChiffres . '})';
$specialChars = preg_quote($policy->listeCharSpeciaux, '/');
if ( $policy->nombreCharSpeciaux > 0 ) {
$regexMdp .= '(?=(?:[^' . $specialChars . '][' . $specialChars . ']){'
. $policy->nombreCharSpeciaux . '})';
}
$allowedChars = 'A-Za-z0-9' . $specialChars;
$regexMdp .= '[' . $allowedChars . ']{' . $policy->longueur . ',}$/uD'; |