List of usage examples for java.util.regex Matcher matches
public boolean matches()
From source file:Main.java
public static String uuidToString(UUID uuid) { String longUUID = uuid.toString(); Pattern pattern = Pattern.compile("0000(.{4})-0000-1000-8000-00805f9b34fb", Pattern.CASE_INSENSITIVE); Matcher matcher = pattern.matcher(longUUID); if (matcher.matches()) { // 16 bit UUID return matcher.group(1); } else {/*from ww w . j ava 2 s . c o m*/ return longUUID; } }
From source file:Main.java
public static boolean isValidEmail(final String emailAddr) { if (TextUtils.isEmpty(emailAddr)) return false; Pattern pattern = Pattern.compile("[\\w\\.\\-]+@([\\w\\-]+\\.)+[\\w\\-]+", Pattern.CASE_INSENSITIVE); Matcher matcher = pattern.matcher(emailAddr); return matcher.matches(); }
From source file:Main.java
public static boolean isNumber(String str) { java.util.regex.Pattern pattern = java.util.regex.Pattern.compile("[0-9.]*"); java.util.regex.Matcher match = pattern.matcher(str); if (match.matches() == false) { return false; } else {/*from w ww .j a v a 2 s. co m*/ return true; } }
From source file:Main.java
/** * Checking if a String matches desired Regex pattern. Used for validating * emails./* w w w. j a v a 2 s . c o m*/ */ public static boolean isMatch(String text, String pattern) { try { Pattern patt = Pattern.compile(pattern); Matcher matcher = patt.matcher(text); return matcher.matches(); } catch (RuntimeException e) { return false; } }
From source file:Main.java
public static boolean isPhoneNumberValid(String phoneNumber) { boolean isValid = false; String expression = "((^(1|2)[0-9][0-9]{9}$)|(^0[1,2]{1}\\d{1}-?\\d{8}$)|(^0[3-9] {1}\\d{2}-?\\d{7,8}$)|(^0[1,2]{1}\\d{1}-?\\d{8}-(\\d{1,4})$)|(^0[3-9]{1}\\d{2}-? \\d{7,8}-(\\d{1,4})$))"; Pattern pattern = Pattern.compile(expression); Matcher matcher = pattern.matcher(phoneNumber); if (matcher.matches()) { isValid = true;/*from www . ja v a2 s .c o m*/ } return isValid; }
From source file:Main.java
public static boolean matches(String content, String format) { Pattern pattern = Pattern.compile(format); Matcher matcher = pattern.matcher(content); boolean matches = matcher.matches(); return matches; }
From source file:Main.java
public static boolean isValidEmail(String email) { boolean isValid = false; String expression = "^[\\w\\.-]+@([\\w\\-]+\\.)+[A-Z]{2,4}$"; CharSequence inputStr = email; Pattern pattern = Pattern.compile(expression, Pattern.CASE_INSENSITIVE); Matcher matcher = pattern.matcher(inputStr); if (matcher.matches()) { isValid = true;/*from w ww .ja v a 2 s . c o m*/ } return isValid; }
From source file:Main.java
public static boolean isNumericString(String numericnum) { boolean isValid = false; // Initialize reg ex for numeric number. String expression = "(*[0-9])"; CharSequence inputStr = numericnum; Pattern pattern = Pattern.compile(expression); Matcher matcher = pattern.matcher(inputStr); if (matcher.matches()) { isValid = true;/*from w w w .j av a 2 s .c o m*/ } return isValid; }
From source file:Main.java
public static boolean isEmail(String email) { String check = "^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$"; Pattern regex = Pattern.compile(check); Matcher matcher = regex.matcher(email); boolean isMatched = matcher.matches(); return isMatched; }
From source file:Main.java
public static boolean isPhoneValid(String phone) { boolean isValid = false; String expression = "^[+]?[0-9]{10,13}$"; CharSequence inputStr = phone; Pattern pattern = Pattern.compile(expression, Pattern.CASE_INSENSITIVE); Matcher matcher = pattern.matcher(inputStr); if (matcher.matches()) { isValid = true;//from ww w . j av a2 s . co m } return isValid; }