List of usage examples for java.util.regex Pattern compile
public static Pattern compile(String regex)
From source file:Main.java
private static boolean isNumeric(String str) { Pattern pattern = Pattern.compile("[0-9]*"); Matcher isNum = pattern.matcher(str); return isNum.matches(); }
From source file:Main.java
public static boolean checkChinese(String username) { String pstr = "[^x00-xff]"; Pattern p = Pattern.compile(pstr); Matcher m = p.matcher(username); return m.find(); }
From source file:Main.java
public static boolean isValidTagAndAlias(String s) { Pattern p = Pattern.compile("^[\u4E00-\u9FA50-9a-zA-Z_-]{0,}$"); Matcher m = p.matcher(s);//from w w w. j a v a 2 s.c om return m.matches(); }
From source file:Main.java
public static boolean isNumeric(String str) { String regEx = "^-?[0-9]+$"; Pattern pat = Pattern.compile(regEx); Matcher mat = pat.matcher(str); if (mat.find()) { return true; } else {//from w ww .java 2 s . c o m return false; } }
From source file:Main.java
public static boolean isNumeric(String str) { Pattern pattern = Pattern.compile("^[0-9]+(.[0-9]*)?$"); Matcher isNum = pattern.matcher(str); return isNum.matches(); }
From source file:Main.java
public static boolean existZH(String str) { String regEx = "[\\u4e00-\\u9fa5]"; Pattern p = Pattern.compile(regEx); Matcher m = p.matcher(str);//from w w w . j a v a2s. c o m while (m.find()) { return true; } return false; }
From source file:Main.java
public static String getWithinTags(String matchString, String tag) { final Pattern pattern = Pattern.compile("<" + tag + ">(.+?)</" + tag + ">"); final Matcher matcher = pattern.matcher(matchString); try {/* w w w .ja v a 2 s .c o m*/ matcher.find(); return matcher.group(1); } catch (Exception e) { System.out.println("An exception has occured within tags: " + e.toString()); return ""; } }
From source file:PatternMethodExample.java
public static void reusePatternMethodExample() { Pattern p = Pattern.compile("\\d"); Matcher matcher = p.matcher("5"); boolean isOk = matcher.matches(); System.out.println("original pattern matches " + isOk); String tmp = p.pattern();//from w ww . j av a2 s . co m Pattern p2 = Pattern.compile(tmp); matcher = p.matcher("5"); isOk = matcher.matches(); System.out.println("second pattern matches " + isOk); }
From source file:Main.java
public static boolean isIdOk(String Idstr) { //account/*from w w w.j av a2 s. c o m*/ String regex = "[\u4e00-\u9fa5_a-zA-Z0-9_]{2,30}"; Pattern pattern = Pattern.compile(regex); return pattern.matcher(Idstr).matches(); }
From source file:Main.java
public static boolean isMatches(String text) { String strPattern = "^[_a-zA-Z0-9]+$"; Pattern p = Pattern.compile(strPattern); Matcher m = p.matcher(text);//from w ww. j a va 2 s. c o m return m.matches(); }