1 package zfc; 2 3 public class Zfc { 4 5 public static void main(String[] args) 6 { 7 //判断手机号格式是否合法 8 String text = "15851678259"; 9 String bj = "1{1}\d{10}"; 10 if(text.matches(bj)) 11 { 12 System.out.println("手机号合法"); 13 } 14 else 15 { 16 System.out.println("手机号不合法"); 17 } 18 } 19 20 }