工具类-校验

/*
 * 手机效验
 * 正确 true
 * 错误 false
 */
public boolean isMobile(String mobiles) {

	Pattern p = Pattern.compile("^1[3|4|5|7|8]\\d{9}$");
	Matcher m = p.matcher(mobiles);
	return m.matches();

}

/*
 * 手机格式校验(11位)
 * 正确 true
 * 错误 false
 */
public boolean isPhone(String mobiles) {

	Pattern p = Pattern.compile("1[3|5|7|8|][0-9]{9}");
	Matcher m = p.matcher(mobiles);
	return m.matches();

}

/*
 * 纯数字效验	
 * 纯数字 true
 * 非纯数字 false
 */
 public boolean isNumber(String str)
	{
		java.util.regex.Pattern pattern=java.util.regex.Pattern.compile("[0-9]*");
		java.util.regex.Matcher match=pattern.matcher(str);
		return match.matches();
	}


 /*
 *  数字字母效验
 *  通过 true 
 *  不通过 false
 */
public boolean isNumberLetter(String str) {
	if (Pattern.matches("^[0-9A-Za-z]{8,16}$", str)) {    
		return true;
	} else {
		return false;
	}
}

/*
 *  只能输入汉字,长度不限
 *  通过 true 
 *  不通过 false
 */
public boolean ischinese(String str) {
	if (Pattern.matches("^[\\u4E00-\\u9FA5\\uF900-\\uFA2D]+$", str)) {        
		return true;
	} else {
		return false;
	}
}

/*
 *  密码英文数字
 *  通过 true 
 *  不通过 false
 */
public boolean isPassword(String str) {
	if (Pattern.matches("[A-Za-z0-9]+", str)) { 
		return true;
	} else {
		return false;
	}
}
	
/**
 * 身份证编码校验
 * @param idCard 校验身份证对象
 * @return  不合法:true 合法:false
 */
public boolean isIdCardCheck(String idCard) {
	if (!StringUtils.isEmpty(idCard) && Pattern.matches("\\d{15}|\\d{18}",idCard)) {
		return true;
	}
	return false;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值