表达式

package com.cardvlaue.sys.common;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

//验证手机号  
public class CheckingTools {
	public static boolean isMobile(String str) {   
        Pattern p = null;  
        Matcher m = null;  
        boolean b = false;   
        p = Pattern.compile("^[1][3,4,5,8,7][0-9]{9}$"); 
        m = p.matcher(str);  
        b = m.matches();   
        return b;  
    }  
	
	 
	//银行卡
	public static boolean isBankCard(String str) {   
        Pattern p = null;  
        Matcher m = null;  
        boolean b = false;   
        p = Pattern.compile("^(\\d{16}|\\d{19})$"); 
        m = p.matcher(str);  
        b = m.matches();   
        return b;  
    }  
	 
	
	public static Boolean isNumberLetter(String str) {
		Boolean isNoLetter = false;
		String expr = "^[A-Za-z0-9][13]+$|[A-Za-z0-9][15]";
		if (str.matches(expr)) {
			isNoLetter = true;
		}
		return isNoLetter;
	}
	
	public static boolean isCharacters(String str) { 
		Pattern p = null;  
        Matcher m = null;  
        boolean b = false;  //"^[a-zA-Z0-9]$|^[a-zA-Z0-9]$"
		String regEx="[`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~!@#¥%……&*()——+|{}【】';:”“’。,、?]";
		p   =   Pattern.compile("^[a-zA-Z0-9]{13,20}$");      
	    m   =   p.matcher(str);  
	    b = m.matches(); 
        return b;  
    }  
	
	
//检查密码
	public static boolean isPwd(String pwd){
        if (pwd.trim().length()<6 || pwd.trim().length()>16)
        	return false;
        return true;
	}
	
//校验身份证
	public static boolean isAuthCard(String card){
        Pattern p = null;  
        Matcher m = null;  
        boolean b = false;   
        p = Pattern.compile("([0-9]{17}([0-9]|X))|([0-9]{15})"); 
        m = p.matcher(card);  
        b = m.matches();   
        return b;  
	}
	
//电话号码验证   电话号码与手机号码同时验证:(^(\d{3,4}-)?\d{7,8})$|(13[0-9]{9})  
	public static boolean isTelphone(String phoneCode){
        Pattern p = null;  
        Matcher m = null;  
        boolean b = false;   
        p = Pattern.compile("^(0[1-9]{2,3}\\-)?([2-9][0-9]{6,7})"); 
        m = p.matcher(phoneCode);  
        b = m.matches();   
        return b;  
		
	}
	
//邮箱验证
	public static boolean isEmail(String email){
        Pattern p = null;  
        Matcher m = null;  
        boolean b = false;   
        p = Pattern.compile("^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$"); 
        m = p.matcher(email);  
        b = m.matches();   
        return b;  
	}
}

你可能感兴趣的:(表达式)