List of usage examples for java.util.regex Matcher find
public boolean find()
From source file:Main.java
public static boolean isMobilePhoneNumber(String number) { String regx = "^(13[0-9]|15[0-9]|18[0-9]|14[5|7])\\d{8}$"; Pattern pattern = Pattern.compile(regx); Matcher matcher = pattern.matcher(number); return matcher.find(); }
From source file:Main.java
public static List<String> getStringDigit(String text) { text = null == text ? "" : text; List<String> digitList = new ArrayList<String>(); Pattern p = Pattern.compile("(\\d+)"); Matcher m = p.matcher(text); while (m.find()) { String find = m.group(1).toString(); digitList.add(find);/*from w w w. ja va 2s. com*/ } return digitList; }
From source file:Main.java
public static boolean haveEmotion(String text) { Matcher matcher = pattern.matcher(text); if (matcher.find()) { return true; } else {/* w w w.j ava 2 s. com*/ return false; } }
From source file:Main.java
public static String getCsFromRE(String pt, String content) { Pattern pa1 = Pattern.compile(pt, Pattern.CASE_INSENSITIVE); Matcher matcher1 = pa1.matcher(content); if (matcher1.find()) { return matcher1.group(1); } else {//from w w w . j av a2s. c o m return ""; } }
From source file:Main.java
/** * Check if a printable string is encoded by Base64 or not * //from w ww . j av a2 s . c o m * @param str * @return */ public static boolean isBase64(String str) { Pattern pattern = Pattern.compile("^(?:[A-Za-z0-9+/_-]{4})*(?:[A-Za-z0-9+/_-]{2}==|[A-Za-z0-9+/_-]{3}=)?$"); Matcher matcher = pattern.matcher(str); return matcher.find(); }
From source file:Main.java
public static String extractMatchString(String regex, String target) { Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(target); if (matcher.find()) { return matcher.group(1); } else {//ww w .j ava 2 s.c om return null; } }
From source file:Main.java
public static int getCurrentPage(String url) { Matcher matcher = PAGE_PATTERN.matcher(url); if (matcher.find()) { return Integer.parseInt(matcher.group(1)); }//from w w w . ja v a 2s . co m return 0; }
From source file:Main.java
public static boolean isPhoneFormat(String phone) { String regExp = "^[1]([3][0-9]{1}|59|58|88|89)[0-9]{8}$"; Pattern p = Pattern.compile(regExp); Matcher m = p.matcher(phone); boolean isCorrect = m.find();// boolean return isCorrect; }
From source file:Main.java
public static Map<String, String> parseCommaDelimitedProps(String s) { if (s == null) return null; Map<String, String> props = new HashMap<String, String>(); Pattern p = Pattern.compile("\\s*([^=\\s]+)\\s*=\\s*([^=\\s,]+)\\s*,?"); //Pattern.compile("\\s*([^=\\s]+)\\s*=\\s([^=\\s]+)\\s*,?"); Matcher matcher = p.matcher(s); while (matcher.find()) { props.put(matcher.group(1), matcher.group(2)); }/*from w w w . j av a 2 s .co m*/ return props; }
From source file:Main.java
public static String getVerifyCodeFromSms(String smsBody) { Pattern pattern = Pattern.compile("\\d{6}"); Matcher matcher = pattern.matcher(smsBody); if (matcher.find()) { return matcher.group(); }/* w w w . ja v a 2 s . c om*/ return null; }