有人能指出我在Android的使用正则表达式(模式和匹配器要具体)验证使用正则表达式
String pass_pattern = "^([A-Za-z0-9][A-Za-z0-9]{4,10})$";
b1= (Button)findViewById(R.id.button1);
et1= (EditText)findViewById(R.id.editText1);
b1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
chek = et1.getText().toString();
if(chek.equals(""))
{
Toast.makeText(getApplicationContext(), "Enter password",1000).show();
}
if(chek.matches(pass_pattern))
{
Toast.makeText(getApplicationContext(), "Valid pAssword",1000).show();
}else {Toast.makeText(getApplicationContext(), "InvalidpAssword",1000).show();}
}
});
这是目前我的代码,我想检查用户输入ATLEAST一个小写字母至少有一个大写字母和一个数字,长度应该是4-10个字符。
如果我通过.matches()来做到这一点,它只会比较上述字符串中的一个条件。
另一个密码验证! – devnull