package chat.tools; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Utils { public static String getRandomCode(int length) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < length; i++) { sb.append(((int)(Math.random()*100))%10); } return sb.toString(); } public static boolean isMobile(String mobile) { boolean flag = false; try { Pattern p = Pattern.compile("^(1[3-9][0-9])\\d{8}$"); Matcher m = p.matcher(mobile); flag = m.matches(); } catch (Exception e) { flag = false; } return flag; } }