如何为以下
编写正则表达式at least 6 characters
at least 1 uppercase
at least 1 lowercase
at least 1 number
at least 1 special character ("#¤%&/( æøå etc.)
我尝试了以下正则表达式,但它无效。
^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[#+-?$!]).{8,}$
答案 0 :(得分:2)
以下正则表达式将满足您的所有条件,
^(?=.{6,})(?=.*?[A-Z])(?=.*?[a-z])(?=.*?\d)(?=.*?\W).*$
(?=.{6,}) at least 6 characters
(?=.*?[A-Z]) at least 1 uppercase
(?=.*?[a-z]) at least 1 lowercase
(?=.*?\d) at least 1 number
(?=.*?\W) at least 1 non-word character