常用正则表达式

来源:互联网 发布:mac清理微信缓存 编辑:程序博客网 时间:2024/06/01 10:47

判断输入,是否是符合规范的密码,或者手机等

遇到新的需求再来更新


/** * 正则表达式集合 */public class VerifyUtils {/** 判断是否只包含汉字,字母和数字 */public static boolean isName(String name) {return Pattern.compile("^[\u4E00-\u9FA5A-Za-z0-9_]+$").matcher(name).matches();}/** 判断是否是手机号码 */public static boolean isPhone(String phone) {return Pattern.compile("(1)\\d{10}").matcher(phone).matches();}/** 判断是否只包含6-20位字母和数字 */public static boolean isPassWord(String pass) {return Pattern.compile("^[a-zA-Z0-9_]+$").matcher(pass).matches();}}


0 0
原创粉丝点击