List of usage examples for java.util.regex Pattern compile
public static Pattern compile(String regex)
From source file:Main.java
public static boolean isWord(String str) { Pattern pattern = Pattern.compile("^[A-Za-z]+$"); Matcher isNum = pattern.matcher(str); if (!isNum.matches()) { return false; } else {/*from w w w .j av a 2 s . c o m*/ return true; } }
From source file:Main.java
public static boolean checkPhoneNumber(String phoneNumber) { Pattern pattern = Pattern.compile("^1[0-9]{10}$"); Matcher matcher = pattern.matcher(phoneNumber); return matcher.matches(); }
From source file:Main.java
private static boolean isPhoneNumber(String number) { Pattern pattern = Pattern.compile("^(13[0-9]|15[0-9]|153|15[6-9]|180|18[23]|18[5-9])\\d{8}$"); Matcher matcher = pattern.matcher(number); if (matcher.matches()) { return true; }// ww w .j a va 2 s . co m return false; }
From source file:Main.java
public static boolean isBankNameValid(String bankName) { String regex = "[A-Z|a-z ]*"; Pattern pattern = Pattern.compile(regex); return pattern.matcher(bankName).matches(); }
From source file:Main.java
public static String IntegerToString(String str) { Pattern p = Pattern.compile("&#[0-9]{5};"); Matcher m = p.matcher(str);//from w ww. ja v a 2 s . c o m String g = ""; String num = ""; char c = 0; while (m.find()) { g = m.group(); num = g.substring(2, 7); c = (char) (Integer.parseInt(num)); str = str.replace(g, "" + c); } return str; }
From source file:Main.java
public static Boolean checkRegex(String regex, String str) { Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(str); return matcher.matches(); }
From source file:Main.java
public static String getParameterFromUrl(String param, String url) { Pattern p = Pattern.compile(param + "=([^&]+)"); Matcher m = p.matcher(url);//from ww w. j av a2 s .c om m.find(); return m.group(1); }
From source file:Main.java
public static boolean isDate(String strDate) { Pattern pattern = Pattern .compile("^((\\d{2}(([02468][048])|([13579][26]))[\\-\\/\\s]?((((0?[13578])|(1[02]))" + "[\\-\\/\\s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\\-\\/\\s]?((0?[1-9])" + "|([1-2][0-9])|(30)))|(0?2[\\-\\/\\s]?((0?[1-9])|([1-2][0-9])))))|(\\d{2}(([02468][1235679])|" + "([13579][01345789]))[\\-\\/\\s]?((((0?[13578])|(1[02]))[\\-\\/\\s]?((0?[1-9])|([1-2][0-9])|" + "(3[01])))|(((0?[469])|(11))[\\-\\/\\s]?((0?[1-9])|([1-2][0-9])|(30)))" + "|(0?2[\\-\\/\\s]?((0?[1-9])" + "|(1[0-9])|(2[0-8]))))))(\\s(((0?[0-9])|([1-2][0-3]))\\:([0-5]?[0-9])" + "((\\s)|(\\:([0-5]?[0-9])))))?$"); Matcher m = pattern.matcher(strDate); return m.matches(); }
From source file:Main.java
public static boolean isNumber(String n) { if (n == null || n.equals("")) return false; return Pattern.compile("[0-9]*").matcher(n).matches(); }
From source file:Main.java
private static void addPattern(Map<Pattern, Integer> map, String smile, int resource) { map.put(Pattern.compile(Pattern.quote(smile)), resource); }