List of usage examples for java.util.regex Pattern compile
public static Pattern compile(String regex)
From source file:Main.java
public static boolean matchPhone(String text) { if (Pattern.compile("^1(3|4|5|7|8)\\d{9}$").matcher(text).matches()) { return true; }//from w w w . ja v a 2s . c om return false; }
From source file:Main.java
public static boolean isMobileNO(String mobiles) { Pattern p = Pattern.compile("^((13[0-9])|(15[^4,\\D])|(18[^4,\\D]))\\d{8}$"); Matcher m = p.matcher(mobiles); return m.matches(); }
From source file:Main.java
public static boolean isMobileNum(String mobiles) { Pattern p = Pattern.compile("^((13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$"); Matcher m = p.matcher(mobiles); System.out.println(m.matches() + "---"); return m.matches(); }
From source file:MatcherResetExample.java
public static void test() { Pattern p = Pattern.compile("\\d"); Matcher m1 = p.matcher("01234"); while (m1.find()) { System.out.println("\t\t" + m1.group()); }//from ww w . j a v a 2 s . c o m m1.reset(); System.out.println("After resetting the Matcher"); while (m1.find()) { System.out.println("\t\t" + m1.group()); } }
From source file:Main.java
public static boolean isValid_phone(String mobiles) { Pattern p = Pattern.compile("^((13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$"); Matcher m = p.matcher(mobiles); return m.matches(); }
From source file:Main.java
public static boolean isPhoneNumber(String str) { Pattern phone = Pattern.compile("^((13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$"); Matcher ma = phone.matcher(str); return ma.matches(); }
From source file:Main.java
public static boolean isDigit(String digit) { String regex = "^[0-9]*$"; Pattern pattern = Pattern.compile(regex); return pattern.matcher(digit).matches(); }
From source file:Main.java
public static boolean validateNumber(String str) { Pattern pattern = Pattern.compile("[0-9]"); Matcher matcher = pattern.matcher(str); return matcher.matches(); }
From source file:Main.java
public static boolean isMobileNo(String phone) { Pattern pattern = Pattern.compile("^((13[0-9])|(15[^4,\\D])|(18[0-9]))\\d{8}$"); Matcher matcher = pattern.matcher(phone); return matcher.matches(); }
From source file:Main.java
public static boolean isPassword(String password) { Pattern p = Pattern.compile("^[\\dA-Za-z(!@#$%&)]{6,16}$"); Matcher m = p.matcher(password); return m.matches(); }