我需要一個正則表達式來匹配以下規則。正則表達式匹配這些規則
1. Atleast 1 numerical character.
2. Atleast 1 of these (!, @, #, $, %, _) non-alphanumeric characters.
3. Uppercase alphabets.
4. Lowercase alphabets
我試着創建一個模式如下,但東西是任何字符都可以在任何位置。我有點卡在這裏。
^[[A-Z]+[a-z]+[0-9]+[[email protected]#\\$%_]+]$
這些應該滿足上述每個條件。
1. [0-9]+
2. [[email protected]#\\$_%]+
3. [A-Z]+
4. [a-z]+
但是,如何將它們組合在一起,以便它們可以以任何順序出現,但每個組都會出現一次。
SOLUTION:
^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[[email protected]#$%_])[[email protected]#$%_]*$
[複雜的密碼正則表達式]的可能的副本(http://stackoverflow.com/questions/3466850/complex-password-regular-expression) – Toto