我想在android中创建包含以下内容的密码模式
我使用了 html5 密码模式
String password_pattern = "(?=^.{8,}$)((?=.*\\d)|(?=.*\\W+))(?![.\\n])(?=.*[A-Z])(?=.*[a-z]).*$";
但它不起作用。
答案 0 :(得分:2)
尝试使用以下Regex,它可以满足您的需求,
1。大写字母
2。降低信件
3。特殊字符
4. 号码
5。最低8位
^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$%^&*-]).{8,}$
检查此链接:
答案 1 :(得分:0)
你可以使用它。
Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed?
模式描述
private static final String PASSWORD_PATTERN = "((?=.*\\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%]).{6,20})";
你可以这样使用
(?=.*\d) # must contains one digit from 0-9
(?=.*[a-z]) # must contains one lowercase characters
(?=.*[A-Z]) # must contains one uppercase characters
(?=.*[@#$%]) # must contains one special symbols in the list "@#$%"
. # match anything with previous condition checking
{6,20} # length at least 6 characters and maximum of 20
详情请Check this