public class RegExpUtil { private static final String IS_NUMBER ="^[0-9]+$"; private static final String IS_USERNAME = "^[a-zA-Z]\\w{5,17}$"; private static final String IS_PASSWORD = "^[a-zA-Z][\\w]{5,17}$"; private static final String IS_EMAIL = "^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$"; private static final String IS_URL = "^http://([\\w-]+\\.)+[\\w-]+(/[\\w-./?%&=]*)?$"; private static final String IS_MOBILE_PHONE = "^((13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$"; //移动电话 手机 private static final String IS_PHONE = "^(((\\d{3,4}-)|(\\d{3,4}-)?)\\d{7,8})|([0-9]{3}-[0-9]{3}-[0-9]{4})$"; //固定电话 private static final String IS_CHINESE = "[\u4e00-\u9fa5]"; public static boolean isNumber(String str){ Pattern p = Pattern.compile(IS_NUMBER); return p.matcher(str).matches(); } public static boolean isUserName(String str){ Pattern p = Pattern.compile(IS_USERNAME); return p.matcher(str).matches(); } public static boolean isPassword(String str){ Pattern p = Pattern.compile(IS_PASSWORD); return p.matcher(str).matches(); } public static boolean isEmail(String str){ Pattern p = Pattern.compile(IS_EMAIL); return p.matcher(str).matches(); } public static boolean isURL(String str){ Pattern p = Pattern.compile(IS_URL); return p.matcher(str).matches(); } public static boolean isMobilePhone(String str){ Pattern p = Pattern.compile(IS_MOBILE_PHONE); return p.matcher(str).matches(); } public static boolean isPhone(String str){ Pattern p = Pattern.compile(IS_PHONE); return p.matcher(str).matches(); } public static boolean isChinese(String str){ Pattern p = Pattern.compile(IS_CHINESE); return p.matcher(str).matches(); } public static boolean isContainBlank(String str){ return str.indexOf(" ")>-1?true:false; } }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。