This article mainly summarizes the commonly used regular verification in Java
public static boolean isMobile(String str) { Pattern p; Matcher m; boolean b; p = Pattern.compile("^[1][3,4,5,6,7,8,9][0-9]{9}$"); // 验证手机号 m = p.matcher(str); b = m.matches(); return b; }
public static boolean checkFieldValueNull(Object obj){ Class> clazz = obj.getClass(); for(; clazz != Object.class ; clazz = clazz.getSuperclass()) { Field[] fields=clazz.getDeclaredFields(); for(Field field:fields){ try { field.setAccessible(true); if("serialVersionUID".equals(field.getName())){ continue; } if (field.get(obj) != null) {//判断字段是否为空,并且对象属性中的基本都会转为对象类型来判断 return false; } } catch (IllegalAccessException e) { e.printStackTrace(); } } } return true; }
url = url.substr(0,7).toLowerCase() == "http://" ? url : "http://" + url;to the URL.
The above is the detailed content of Summary of regular verification frequently used in Java development. For more information, please follow other related articles on the PHP Chinese website!