/**
* 必须包含数字、中文、字母
* www.yoodb.com
* @param str
* @return
*/
public static boolean isLetterDigit(String str) {
boolean isDigit = false;
boolean isLetter = false;
for (int i = 0; i < str.length(); i++) {
if (Character.isDigit(str.charAt(i))) {
isDigit = true;
}
if (Character.isLetter(str.charAt(i))) {
isLetter = true;
}
}
String regex = "^[a-zA-Z0-9]+$";
boolean isRight = isDigit && isLetter && str.matches(regex);
return isRight;
}
/**
* 必须包含数字、中文、字母
* @param str
* www.yoodb.com
* @return
*/
String txt = edInput.getText().toString();
Pattern p = Pattern.compile("[0-9]*");
Matcher m = p.matcher(txt);
if(m.matches() ){
Toast.makeText(Main.this,"输入是数字!", Toast.LENGTH_SHORT).show();
}
p = Pattern.compile("[a-zA-Z]");
m = p.matcher(txt);
if(m.matches()){
Toast.makeText(Main.this,"输入是字母!", Toast.LENGTH_SHORT).show();
}
p = Pattern.compile("[\u4e00-\u9fa5]");
m = p.matcher(txt);
if(m.matches()){
Toast.makeText(Main.this,"输入是汉字!", Toast.LENGTH_SHORT).show();
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有