package cn.check.com; import java.util.Scanner; public class CheckPhoneDemo { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc=new Scanner(System.in); System.out.println("请输入:"); String phone=sc.nextLine(); String regex="1[38]\d{9}";//首个数字为1,第二个数字是3或者8,//d是0-9的数字,{9}后面还有9位数字 boolean flag= phone.matches(regex); System.out.println(flag); } }