List of usage examples for java.util.regex Pattern matcher
public Matcher matcher(CharSequence input)
From source file:Main.java
public static String replace(String string) { Pattern pattern = Pattern.compile(".*?"); Matcher matcher = pattern.matcher(string); return matcher.replaceAll("$1").trim(); }
From source file:Main.java
private static boolean Regular(String str, String pattern) { if (null == str || str.trim().length() <= 0) return false; Pattern p = Pattern.compile(pattern); Matcher m = p.matcher(str); return m.matches(); }
From source file:Main.java
public static boolean checkEmail(String s) { String check = "^([a-z0-9A-Z_-]+[-|\\.]?)+[a-z0-9A-Z_]@([a-z0-9A-Z_]+(-[a-z0-9A-Z_]+)?\\.)+[a-zA-Z\\.]{2,}$"; Pattern regex = Pattern.compile(check); Matcher matcher = regex.matcher(s); return matcher.matches(); }
From source file:Main.java
public static boolean isLetter(String str) { if (str == null || str.length() < 0) { return false; }//from w w w . ja va 2 s. com Pattern pattern = Pattern.compile("[\\w\\.-_]*"); return pattern.matcher(str).matches(); }
From source file:Main.java
public static boolean checkEmailValid(String email) { if ((email == null) || (email.trim().length() == 0)) { return false; }/*from w w w . j a va 2 s. com*/ String regEx = "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,4}$"; Pattern p = Pattern.compile(regEx); Matcher m = p.matcher(email.trim().toLowerCase()); return m.find(); }
From source file:Main.java
public static boolean isNumber(String str) { String NUMBER_PATTERN = "^\\d+$"; Pattern p = Pattern.compile(NUMBER_PATTERN); Matcher m = p.matcher(str); return m.matches(); }
From source file:Main.java
private static boolean isEmail(String text) { String reg = "^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$"; Pattern regex = Pattern.compile(reg); Matcher matcher = regex.matcher(text); return matcher.matches(); }
From source file:Main.java
public static boolean matcherRegex(String regex, String str) { Pattern pattern = Pattern.compile(regex); return pattern.matcher(str).matches(); }
From source file:Main.java
public static boolean isNumeric(String str) { Pattern pattern = Pattern.compile("^[-\\+]?[.\\d]*$"); return pattern.matcher(str).matches(); }
From source file:Main.java
private static String getFileNameByUrl(String url) { // TODO Auto-generated method stub Pattern p = Pattern.compile("\\w+"); Matcher m = p.matcher(url); String filename = ""; while (m.find()) { String str = m.group();/* w w w . j ava 2 s. c o m*/ filename = str; } return filename; }