List of usage examples for java.util.regex Matcher matches
public boolean matches()
From source file:Main.java
public static boolean isMobileNum(String mobiles) { Pattern p = Pattern.compile("^((13[0-9])|(15[^4,\\D])|(17[0-9])|(14[0-9])|(18[0-9]))\\d{8}$"); Matcher m = p.matcher(mobiles); return !TextUtils.isEmpty(mobiles) && m.matches(); }
From source file:Main.java
/** * to validate Hex format/* www.j a va2 s .co m*/ * @author wajdihh * * @param pHex * * @return true is validate */ public static boolean isValidHex(String pHex) { Pattern lPattern = Pattern.compile("^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$"); Matcher lMatcher = lPattern.matcher(pHex); return lMatcher.matches(); }
From source file:Main.java
public static String checkMobileNum(String phoneNum) { if (TextUtils.isEmpty(phoneNum)) return ""; Pattern p1 = Pattern.compile("^((\\+{0,1}86){0,1})1[0-9]{10}"); Matcher m1 = p1.matcher(phoneNum); if (m1.matches()) { Pattern p2 = Pattern.compile("^((\\+{0,1}86){0,1})"); Matcher m2 = p2.matcher(phoneNum); StringBuffer sb = new StringBuffer(); while (m2.find()) { m2.appendReplacement(sb, ""); }// w ww . ja va2 s . c om m2.appendTail(sb); return sb.toString(); } else { return phoneNum; } }
From source file:Main.java
public static boolean isMobile(String mobile) { Pattern pattern = Pattern.compile("1[3458]\\d{9}"); Matcher matcher = pattern.matcher(mobile); boolean b = matcher.matches(); if (b)// ww w .j a v a 2 s.c om return true; else return false; }
From source file:Main.java
public static boolean isPhoneNumber(String phoneNum) { String expression = "^((13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$"; CharSequence inputStr = phoneNum; Pattern pattern = Pattern.compile(expression); Matcher matcher = pattern.matcher(inputStr); if (matcher.matches()) { return true; }//from w w w . j av a 2 s . c om return false; }
From source file:Main.java
/** * Swap the size of a sized image url, returning the new url. * /*from w w w . j a va 2 s. c o m*/ * Sized image urls encode the image (jpg, jpeg or png) with the image size at the suffix of the url. * * For example: http://www.example.com/image_50.jpg With replacement 100 would return: http://www.example.com/image_100.jpg * * @param url The sized image url. * @param size The new size of the image */ public static String swapSizedImageUrlSize(String url, int size) { if (url == null) throw new IllegalArgumentException("url cannot be null"); Matcher matcher = SIZED_IMAGE_URL_PATTERN.matcher(url); if (!matcher.matches()) return url; return matcher.group(1) + size + "." + matcher.group(2); }
From source file:Main.java
public static boolean isEnglish(String english) { Pattern pattern = Pattern.compile("^[A-Za-z]+$"); Matcher m = pattern.matcher(english); if (m.matches()) { return true; } else {/* ww w . j a va 2s .co m*/ return false; } }
From source file:Main.java
public static boolean isSipAddress(String numberOrAddress) { Pattern p = Pattern.compile(sipAddressRegExp); Matcher m = p.matcher(numberOrAddress); return m != null && m.matches(); }
From source file:Main.java
public static boolean isStrictSipAddress(String numberOrAddress) { Pattern p = Pattern.compile(strictSipAddressRegExp); Matcher m = p.matcher(numberOrAddress); return m != null && m.matches(); }
From source file:Main.java
public static boolean isNumber(String str) { if (isLong(str)) { return true; }// www .ja v a2 s. c o m Pattern pattern = Pattern.compile("(-)?(\\d*)\\.{0,1}(\\d*)"); Matcher isNum = pattern.matcher(str); if (!isNum.matches()) { return false; } return true; }