List of usage examples for java.util.regex Pattern matcher
public Matcher matcher(CharSequence input)
From source file:Main.java
public static ArrayList<String> getMatchString(String origin, String pattern, int groupId) { ArrayList<String> datas = new ArrayList<>(); Pattern p = Pattern.compile(pattern); Matcher m = p.matcher(origin); while (m.find()) { datas.add(m.group(groupId));/* ww w .java 2s . c o m*/ } return datas; }
From source file:Main.java
public static String getStringDigits(String text) { text = null == text ? "" : text; StringBuilder digitList = new StringBuilder(""); Pattern p = Pattern.compile("(\\d+)"); Matcher m = p.matcher(text); while (m.find()) { String find = m.group(1).toString(); digitList.append(find);/*w w w .jav a 2 s . c om*/ } return digitList.toString(); }
From source file:Main.java
public static boolean isValidCharacters(String s) { Pattern p = Pattern.compile("^[0-9a-zA-Z]{6,9}$"); Matcher m = p.matcher(s); return m.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 validEmail(String email) { String regex = "^[a-z0-9A-Z_-]+@[a-z0-9A-Z_-]+(\\.[a-z0-9A-Z_-]+)+$"; Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(email); return matcher.matches(); }
From source file:Main.java
static public Boolean emailValidation(String email) { Pattern p = Pattern.compile(email_pattern); Matcher m = p.matcher(email); while (m.find()) { return true; }//from w w w. j a va2 s .co m return false; }
From source file:Main.java
public static Boolean validPhone(String phone) { String regex = "^1[3-8]{1}[0-9]{9}$"; Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(phone); return matcher.matches(); }
From source file:Main.java
public static boolean isHKPhoneLegal(String str) throws PatternSyntaxException { String regExp = "^(5|6|8|9)\\d{7}$"; Pattern p = Pattern.compile(regExp); Matcher m = p.matcher(str); return m.matches(); }
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 matches(String content, String format) { Pattern pattern = Pattern.compile(format); Matcher matcher = pattern.matcher(content); boolean matches = matcher.matches(); return matches; }