package my;
public class number {
public static void main(String[] args) {
String s1 = "11024588795";
String s2 = "15044268138";
System.out.println(check(s1));
System.out.println(check(s2));
}
public static String check(String handset) {
String regex = "1[3,5,8]\\d{9}$";
if (handset.matches(regex)){
return handset +"\n是合法的手机号";
}
else{
return handset + "\n不是合法的手机号";
}
}
}
效果如下: