liuxiaolong
2019-05-06 a7bed6b4cfecd61ec153818945f982c5bb796b98
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package com.cloud.common.utils;
 
import java.util.regex.Matcher;
import java.util.regex.Pattern;
 
/**
 *
 * @author lp
 * @date 2018-08-05
 */
public class PhoneUtil {
 
    private static String REGEX = "^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(17[013678])|(18[0,5-9]))\\d{8}$";
    private static Pattern P = Pattern.compile(REGEX);
 
    /**
     * 校验手机号
     *
     * @param phone
     * @return
     */
    public static boolean checkPhone(String phone) {
        int phoneLength = 11;
        if (phone == null || phone.length() != phoneLength) {
            return Boolean.FALSE;
        }
 
        Matcher m = P.matcher(phone);
        return m.matches();
    }
}