List of usage examples for java.util.regex Pattern CASE_INSENSITIVE
int CASE_INSENSITIVE
To view the source code for java.util.regex Pattern CASE_INSENSITIVE.
Click Source Link
From source file:Main.java
public static String getYoutubeVideoId(String url) { Pattern pattern = Pattern.compile("^https?://.*(?:youtu.be/|v/|u/\\w/|embed/|watch?v=)([^#&?]*).*$", Pattern.CASE_INSENSITIVE); Matcher matcher = pattern.matcher(url); if (!matcher.matches()) throw new IllegalArgumentException("Regex fail. not matched. Url: " + url); return matcher.group(1); }
From source file:Main.java
public static boolean validateEmailAddress(String email) { Pattern pattern = Pattern.compile(EMAIL_REGEX, Pattern.CASE_INSENSITIVE); Matcher matcher = pattern.matcher(email); return matcher.matches(); }
From source file:Main.java
public static boolean isPhoneValid(String phone) { boolean isValid = false; String expression = "^[+]?[0-9]{10,13}$"; CharSequence inputStr = phone; Pattern pattern = Pattern.compile(expression, Pattern.CASE_INSENSITIVE); Matcher matcher = pattern.matcher(inputStr); if (matcher.matches()) { isValid = true;/*from w w w . ja v a 2s .c om*/ } return isValid; }
From source file:Main.java
public static boolean isValidCardNumber(String cardNumber) { boolean isValid = false; String expression = "^.{12,16}$"; CharSequence inputStr = cardNumber; Pattern pattern = Pattern.compile(expression, Pattern.CASE_INSENSITIVE); Matcher matcher = pattern.matcher(inputStr); if (matcher.matches()) { isValid = true;//from w ww .ja v a 2s . c o m } return isValid; }
From source file:Main.java
public static List<String> matcherList(String regx, String content, int groupIndex) { List<String> ls = new ArrayList<String>(); Pattern pattern = Pattern.compile(regx, Pattern.CASE_INSENSITIVE); Matcher matcher = pattern.matcher(content); while (matcher.find()) { ls.add(matcher.group(groupIndex)); }/*from w w w . j a v a 2 s. c o m*/ return ls; }
From source file:Main.java
public static boolean isValidEmail(final String emailAddr) { if (TextUtils.isEmpty(emailAddr)) return false; Pattern pattern = Pattern.compile("[\\w\\.\\-]+@([\\w\\-]+\\.)+[\\w\\-]+", Pattern.CASE_INSENSITIVE); Matcher matcher = pattern.matcher(emailAddr); return matcher.matches(); }
From source file:Main.java
public static boolean isUserNameValid(String username) { boolean isValid = false; String expression = "^[a-zA-Z0-9_-]{5,10}$"; CharSequence inputStr = username; Pattern pattern = Pattern.compile(expression, Pattern.CASE_INSENSITIVE); Matcher matcher = pattern.matcher(inputStr); if (matcher.matches()) { isValid = true;// w w w . ja va 2s . com } return isValid; }
From source file:Main.java
public static String getHrefInnerHtml(String href) { if (isEmpty(href)) { return ""; }/*from w w w . j a va2 s .c o m*/ String hrefReg = ".*<[\\s]*a[\\s]*.*>(.+?)<[\\s]*/a[\\s]*>.*"; Pattern hrefPattern = Pattern.compile(hrefReg, Pattern.CASE_INSENSITIVE); Matcher hrefMatcher = hrefPattern.matcher(href); if (hrefMatcher.matches()) { return hrefMatcher.group(1); } return href; }
From source file:Main.java
public static boolean isValidEmail(String email) { boolean isValid = false; String expression = "^[\\w\\.-]+@([\\w\\-]+\\.)+[A-Z]{2,4}$"; CharSequence inputStr = email; Pattern pattern = Pattern.compile(expression, Pattern.CASE_INSENSITIVE); Matcher matcher = pattern.matcher(inputStr); if (matcher.matches()) { isValid = true;//from ww w.j a v a 2 s . c om } return isValid; }
From source file:Main.java
public static boolean isValidEmail(CharSequence target) { if (target == null) return false; Pattern pattern = Pattern.compile(EMAIL_PATTERN, Pattern.CASE_INSENSITIVE); Matcher matcher = pattern.matcher(target); return matcher.matches(); }