List of usage examples for java.util.regex Pattern compile
public static Pattern compile(String regex)
From source file:Main.java
public static boolean stringMatchesPattern(String s, String patt) { Pattern compiledPatt = Pattern.compile(patt); Matcher match = compiledPatt.matcher(s); return match.matches(); }
From source file:Main.java
public static String getClassNameFromTableName(String tableName) { Pattern p = Pattern.compile("(_+|^)(\\w?)"); Matcher m = p.matcher(tableName); StringBuffer sb = new StringBuffer(); while (m.find()) { m.appendReplacement(sb, m.group(2).toUpperCase()); }//from w w w .ja va2 s. c o m m.appendTail(sb); return sb.toString(); }
From source file:Main.java
public static boolean isIFSCValid(String ifsc) { String regex = "[A-Z|a-z]{4}[0][A-Z|a-z|0-9]{6}$"; Pattern pattern = Pattern.compile(regex); return pattern.matcher(ifsc).matches(); }
From source file:Main.java
public static boolean isMobileNO(String mobiles) { Pattern p = Pattern.compile("^((13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$"); Matcher m = p.matcher(mobiles); Log.i("BaseUtils-->isMobileNO-->", m.matches() + ""); return m.matches(); }
From source file:Main.java
public static String getFileName(String path) { Pattern pattern = Pattern.compile("[^\\" + File.separator + "]+.xml"); Matcher matcher = pattern.matcher(path); if (matcher.find()) return matcher.group().substring(0, matcher.group().length() - 4); return ""; }
From source file:Main.java
private static int[] getIndex(String text, String regex) { Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(text); int[] data = new int[2]; // Check all occurrences while (matcher.find()) { data[0] = matcher.start();//from w ww .ja v a 2 s . com data[1] = matcher.end(); // System.out.print("Start index: " + matcher.start()); // System.out.print(" End index: " + matcher.end()); // System.out.println(" Found: " + matcher.group()); } return data; }
From source file:Main.java
public static String getDigital(String str) { String regEx = "[^0-9]"; Pattern p = Pattern.compile(regEx); Matcher m = p.matcher(str);//from www.ja v a 2 s. c o m return m.replaceAll("").trim(); }
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 {/*from w w w . jav a2 s. c o m*/ return null; } }
From source file:Main.java
public static String getAttributeNameFromColName(String tableName) { Pattern p = Pattern.compile("_+(\\w?)"); Matcher m = p.matcher(tableName); StringBuffer sb = new StringBuffer(); while (m.find()) { if (m.start() != 0) m.appendReplacement(sb, m.group(1).toUpperCase()); else// ww w.j a v a2s . c o m m.appendReplacement(sb, m.group(1).toLowerCase()); } m.appendTail(sb); return sb.toString(); }
From source file:Main.java
public static boolean onlyWord(String content) { boolean flag = false; Pattern p = Pattern.compile("[a-zA-Z\\u4E00-\\u9FA5]+"); Matcher m = p.matcher(content); if (m.matches()) { flag = true;/* ww w. ja va 2s . c o m*/ } return flag; }