zhangzengfei
2022-01-10 4496b59ab27d569df1da7ef634e02273b3a9618a
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.basic.security.utils;
 
import java.util.regex.Matcher;
import java.util.regex.Pattern;
 
public class PhoneNumberCheckUtils {
 
    public static boolean isPhone(String phone) {
 
        String regex = "^((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}$";
 
        if (phone.length() != 11) {
 
//            ToastUtil.show("手机号应为11位数");
            return false;
 
        } else {
 
            Pattern p = Pattern.compile(regex);
            Matcher m = p.matcher(phone);
            boolean isMatch = m.matches();
 
//            if (!isMatch) {
//                ToastUtil.show("请填入正确的手机号");
//            }
            return isMatch;
        }
 
    }
 
}