public static boolean checkChinese(String sequence) { final String format = "[//u4E00-//u9FA5//uF900-//uFA2D]"; boolean result = false; Pattern pattern = Pattern.compile(format); Matcher matcher = pattern.matcher(sequence); result = matcher.find(); return result; }
检测字符串中只能包含:中文、数字、下划线(_)、横线(-)
public static boolean checkNickname(String sequence) { final String format = "[^//u4E00-//u9FA5//uF900-//uFA2D//w-_]"; Pattern pattern = Pattern.compile(format); Matcher matcher = pattern.matcher(sequence); return !matcher.find(); }
获取中间有*号的手机号
public static String getPhonePass(String phone) { if (null == phone || "".equals(phone) || phone.length() < 11) { return ""; } String passA = phone.substring(0, 3); String passB = phone.substring(phone.length() - 3, phone.length()); return passA + "*****" + passB; }
获取中间有*号的身份证号
public static String getPidPass(String pid) { if (null == pid || "".equals(pid) || pid.length() < 18) { return ""; } String passA = pid.substring(0, 3); String passB = pid.substring(pid.length() - 3, pid.length()); return passA + "*****" + passB; }
</div> </div>