手机号工具类:PhoneUtils

package com.msic.mall.common.util;


import io.micrometer.core.instrument.util.StringUtils;

import java.util.regex.Pattern;

public class PhoneNoUtils {
    //电话号码工具类

    //2019最新手机号码正则表达式
    private static final String CELL_PHONE_NO_REGX="^((\\+?86)|(\\(\\+86\\)))?((((13[^4]{1})|(14[5-9]{1})|147|(15[^4]{1})|166|(17\\d{1})|(18\\d{1})|(19[89]{1}))\\d{8})|((134[^9]{1}|1410|1440)\\d{7}))$";




    /**
     * 校验手机号码
     * @param cellPhoneNo
     * @return
     */
    public static boolean checkCellPhoneNo(String cellPhoneNo){

        boolean flag=false;

//        if(StringUtils.isNotBlank(cellPhoneNo) && Pattern.matches(CELL_PHONE_NO_REGX, cellPhoneNo)){
//            flag=true;
//        }

        if(StringUtils.isNotBlank(cellPhoneNo)){

            String numRegx="^\\d{11}$";
            if(Pattern.matches(numRegx,cellPhoneNo)){
                flag=true;
            }


        }


        return flag;
    }

}

 

你可能感兴趣的:(java,正则表达式)