如何用正则表达式判断手机号格式正不正确
import java.util.Scanner; public class test_01 { public static void main(String args[]) { Scanner sc = new Scanner(System.in); String regex = "(13[0-9]|15[012356789]|18[056789])\\d{8}"; /*正则表达式含义: 1.11位手机号 2.前三位数字可以是130,131,132,133, 134,135,136,137,138,139.150,151, 152,153,155,156,157,158,159,180, 185,186,187,188,189 */ while(true) { String phone = sc.nextLine();//输入电话号码 //if选择结构,判断电话号码是否匹配格式 if(phone.matches(regex)) { System.out.println("right"); }else { System.out.println("error"); } } } }