List of usage examples for java.util.regex Pattern compile
public static Pattern compile(String regex)
From source file:Main.java
public static boolean validEmail(String email) { Pattern p = Pattern.compile("^[a-zA-Z0-9][a-zA-Z0-9-_.]+?@([a-zA-Z0-9]+(?:\\.[a-zA-Z0-9-_]+){1,})$"); Matcher m = p.matcher(email); return m.matches(); }
From source file:Main.java
public static boolean checkIDCard(String idCard) { Pattern p = Pattern.compile("^(\\d{15}|\\d{17}[\\dxX])$"); Matcher m = p.matcher(idCard); return m.matches(); }
From source file:Main.java
public static boolean isPhone(String inputText) { Pattern p = Pattern.compile("^((13[0-9])|(15[^4,\\D])|(18[0,0-9]))\\d{8}$"); Matcher m = p.matcher(inputText); return m.matches(); }
From source file:Main.java
public static boolean isSpecialChar(String str) { Pattern p = Pattern.compile("[!*'\"();:@&=+$,/?%#%]"); Matcher m = p.matcher(str);//from ww w.ja v a2 s. c om return m.find(); }
From source file:Main.java
public static boolean MatchPhone(String name) { Pattern p = Pattern.compile("^((13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$"); Matcher m = p.matcher(name);//w w w . ja v a2s. com return m.matches(); }
From source file:Main.java
public static boolean checkEmail(String email) { Pattern p = Pattern.compile("\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*"); Matcher m = p.matcher(email); return m.find(); }
From source file:Main.java
public static boolean isMobileNO(String mobiles) { Pattern p = Pattern.compile("^\\d{11}$"); Matcher m = p.matcher(mobiles); return m.matches(); }
From source file:Main.java
public static boolean isUserName(String mobiles) { Pattern p = Pattern.compile("^[A-Za-z\u4e00-\u9fa5]{2,15}$"); Matcher m = p.matcher(mobiles); return m.matches(); }
From source file:Main.java
public static boolean checkPhone(String phone) { Pattern p = Pattern.compile( "^(((13[0-9])|(14[5,7])|(17[0|5-8])|(15([0-3]|[5-9]))|(18([0-9])))\\d{8})|(0\\d{2}-\\d{8})|(0\\d{3}-\\d{7})$"); Matcher m = p.matcher(phone); return m.matches(); }
From source file:Main.java
public static boolean checkPhone_2(String phone) { Pattern p = Pattern.compile("^1\\d{10}$"); Matcher m = p.matcher(phone); return m.matches(); }