package com.smppw.utils;

import org.apache.commons.lang3.StringUtils;

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

public class CheckUtil {

    public static Boolean isCellPhoneNum(String cellPhoneNum){
        if (cellPhoneNum.length() != 11) {
            System.out.print("手机号应为11位数 ");
            return false;
        }else{
            String regPattern =  "^((13[0-9])|(14[5,7,9])|(15([0-3]|[5-9]))|(166)|(17[0,1,3,5,6,7,8])|(18[0-9])|(19[8|9]))\\d{8}$";
            Pattern pattern = Pattern.compile(regPattern);
            Matcher matcher = pattern.matcher(cellPhoneNum);
            boolean isMatch = matcher.matches();
            return isMatch;
        }
    }

    public static boolean isEmail(String str) {
        String tegex="[a-zA-Z0-9_]+@\\w+(\\.com|\\.cn){1}";
        boolean flag=str.matches(tegex);
        return flag;
    }

    public static boolean isUserName(String str) {
        return !StringUtils.isEmpty(str) && str.length() <= 50;
    }
}
