List of usage examples for java.util.regex Pattern matcher
public Matcher matcher(CharSequence input)
From source file:Main.java
public static boolean isNumeric(CharSequence str) { Pattern pattern = Pattern.compile("[0-9]*"); return pattern.matcher(str).matches(); }
From source file:Main.java
public static boolean isValidPassword(String password) { String str = "^[0-9a-zA-Z]{6,20}$"; Pattern p = Pattern.compile(str); Matcher m = p.matcher(password); return m.matches(); }
From source file:Main.java
public static boolean isCorrectEmail(String email) { String str = "^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$"; Pattern p = Pattern.compile(str); Matcher m = p.matcher(email); return m.matches(); }
From source file:Main.java
public static boolean isValidUserName(String username) { String str = "^[0-9a-zA-Z_]{6,12}$"; Pattern p = Pattern.compile(str); Matcher m = p.matcher(username); return m.matches(); }
From source file:Main.java
public static boolean isDigit(String digit) { String regex = "^[0-9]*$"; Pattern pattern = Pattern.compile(regex); return pattern.matcher(digit).matches(); }
From source file:Main.java
/** * Phone number validation Regular Expressions * * @param input input/*from w w w . jav a2 s.c o m*/ * @return true or false */ public static boolean isPhoneNumber(String input) { String regex = "^\\d{7,8}$|^\\d{3,4}-\\d{7,8}$|^1[3|4|5|8][0-9]\\d{4,8}$"; Pattern p = Pattern.compile(regex); return p.matcher(input).matches(); }
From source file:Main.java
public static boolean isSpecial(String str) { String regex = "[^~{}|\"#]{1,}"; Pattern p = Pattern.compile(regex); Matcher m = p.matcher(str); return m.matches(); }
From source file:Main.java
public static boolean isCorrect(String rgx, String res) { Pattern p = Pattern.compile(rgx); Matcher m = p.matcher(res); return m.matches(); }
From source file:Main.java
public static boolean isNumer(String str) { Pattern pattern = Pattern.compile("[0-9]*"); return pattern.matcher(str).matches(); }
From source file:Main.java
public static boolean isChinese(String str) { String regEx = "[\\u4e00-\\u9fa5]+"; Pattern p = Pattern.compile(regEx); Matcher m = p.matcher(str); return m.find(); }