public class test { public static void main(String[] args) throws Exception { String mobile1="12345677890"; String mobile2="17101530373,18301333333"; boolean b=isMobile(mobile1); boolean b2=isMobile(mobile2); System.out.println(b+"--"+b2); } public static boolean isMobile(String mobile) { boolean flag=false; if(mobile.length()==0){ return false; } String[] mobiles=mobile.split(","); int len=mobiles.length; if(len==1){ return Pattern.matches("^((13[0-9])|(14[5,7,9])|(15[^4,\\D])|(17[0,1,3,5-8])|(18[0-9]))\\d{8}$", mobile); }else{ for(int i=0;i<len;i++){ if(isMobile(mobiles[i])){ flag=true; }else{ flag=false; } } } return flag; } }