List of usage examples for java.util.regex Pattern matcher
public Matcher matcher(CharSequence input)
From source file:Main.java
public static boolean isNumber(String str) { if (str == null || str.length() < 1) { return false; }/* ww w.ja va 2s.c om*/ Pattern pattern = Pattern.compile("[0-9]*.[0-9]*"); return pattern.matcher(str).matches(); }
From source file:Main.java
public static boolean quanshiling(String number) { Pattern pattern = Pattern.compile("^0++$"); Matcher m = pattern.matcher(number); if (m.matches()) { return false; } else {/*from w w w .j ava 2s .c o m*/ return true; } }
From source file:Main.java
public static boolean isPassword(String str) { Pattern p = Pattern.compile("^[a-zA-Z0-9]{6,12}$"); Matcher m = p.matcher(str); return m.matches(); }
From source file:Main.java
public static boolean isEmail(String email) { String regExp = "^([a-zA-Z0-9]*[-_]?[a-zA-Z0-9]+)*@([a-zA-Z0-9]*[-_]?[a-zA-Z0-9]+)+[\\.][A-Za-z]{2,3}([\\.][A-Za-z]{2})?$"; Pattern pattern = Pattern.compile(regExp); Matcher matcher = pattern.matcher(email); return matcher.matches(); }
From source file:Main.java
public static boolean isMatcherStr(String rex, String data) { Pattern pattern = Pattern.compile(rex); Matcher isNum = pattern.matcher(data); if (isNum.matches()) { return true; }// w ww .j av a 2 s .co m return false; }
From source file:Main.java
@Nonnull public static String stripComments(@Nonnull String source) { Pattern pattern = Pattern.compile("#(.*)"); Matcher matcher = pattern.matcher(source); return matcher.replaceAll(""); }
From source file:Main.java
public static boolean vertifyIsUrl(String str) { String regex = "http(s)?://([\\w-]+\\.)+[\\w-]+(/[\\w- ./?%&=]*)?"; Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(str); return matcher.matches(); }
From source file:Main.java
private static boolean match(String regex, String str) { Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(str); return matcher.matches(); }
From source file:Main.java
static boolean hasDoubleByteCharacters(String text) { // Pattern p = Pattern.compile("[^[a-z][A-Z][0-9][.;'\":!]"); Pattern p = Pattern.compile("[^p{Alnum}p{Punct}]"); Matcher m = p.matcher(text); return m.find(); }
From source file:Main.java
/** * Validate an email address//from w w w . ja v a2 s .c om * @param email email to validate * @return return true if email address is valid otherwise false */ @TargetApi(Build.VERSION_CODES.FROYO) public static boolean validateEmailAsPerAndroid(String email) { final Pattern pattern = Patterns.EMAIL_ADDRESS; return pattern.matcher(email).matches(); }