List of usage examples for java.util.regex Pattern matcher
public Matcher matcher(CharSequence input)
From source file:Main.java
public static String replaceBlank(String str) { String dest = ""; if (str != null) { Pattern p = Pattern.compile("\\s*|\t|\r|\n"); Matcher m = p.matcher(str); dest = m.replaceAll(""); }/*from www .ja va2 s . c om*/ return dest; }
From source file:ddf.catalog.content.data.impl.ContentItemValidator.java
private static void validateInput(final String input, Pattern pattern) { if (!pattern.matcher(input).matches()) { throw new IllegalArgumentException("Illegal characters found while validating [" + input + "]. Allowable values must match: " + pattern.pattern()); }/* w ww .jav a 2 s .c o m*/ }
From source file:Main.java
public static boolean isLong(String str) { if ("0".equals(str.trim())) { return true; }//from www .j av a2s .c om Pattern pattern = Pattern.compile("^[^0]\\d*"); Matcher isNum = pattern.matcher(str); return isNum.matches(); }
From source file:Main.java
public static boolean isPuleNumber(String str) { if (TextUtils.isEmpty(str)) { return false; }//from w ww. ja v a 2 s .c o m String reg = "^\\d*"; Pattern pattern = Pattern.compile(reg); Matcher matcher = pattern.matcher(str); boolean flag = matcher.matches(); return flag; }
From source file:Main.java
private static boolean matchRegular(String param, String regular) { if (isValidText(param)) return false; Pattern pattern = Pattern.compile(regular); return pattern.matcher(param).matches(); }
From source file:Main.java
public static boolean isMobileNO(String cellphone) { Pattern p = Pattern.compile("^[1][34578]\\d{9}$"); Matcher m = p.matcher(cellphone); if (!TextUtils.isEmpty(cellphone)) { return m.matches(); }/*from w w w .j a va 2 s . c o m*/ return false; }
From source file:Main.java
public static boolean isName(String str) { Pattern p = Pattern.compile("^[\\u4E00-\\u9FFF]+$"); Matcher matcher = p.matcher(str); return matcher.matches(); }
From source file:Main.java
public static String getFileName(String fileName) { Pattern p_ext = Pattern.compile(pattern); Matcher m_ext = p_ext.matcher(fileName); if (m_ext.find()) { return fileName.substring(0, fileName.indexOf(m_ext.group())); } else {// ww w.jav a 2s . co m return fileName; } }
From source file:Main.java
public static boolean isHttp(String url) { Pattern patt = Pattern.compile(regex); Matcher matcher = patt.matcher(url); return matcher.matches(); }
From source file:Main.java
public static boolean matchMobilNo(String num) { if (TextUtils.isEmpty(num)) { return false; }//from ww w . ja va 2 s .com String reg = "^((13[0-9])|(14[5,7])|(15[^4,\\D])|(17[0,6,7])|(18[0-9]))\\d{8}$"; Pattern pattern = Pattern.compile(reg); Matcher matcher = pattern.matcher(num); boolean flag = matcher.matches(); return flag; }