1、修复url匹配正则
2、部分onclick处理 3、代码整理
This commit is contained in:
@ -1,7 +1,8 @@
|
||||
package com.gh.common.util;
|
||||
|
||||
import android.util.Patterns;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* @author CsHeng
|
||||
@ -11,19 +12,19 @@ import java.util.regex.Pattern;
|
||||
|
||||
public class PatternUtils {
|
||||
|
||||
public static final Pattern VALID_EMAIL_ADDRESS_REGEX =
|
||||
Pattern.compile("^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,6}$", Pattern.CASE_INSENSITIVE);
|
||||
// public static final Pattern VALID_EMAIL_ADDRESS_REGEX =
|
||||
// Pattern.compile("^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,6}$", Pattern.CASE_INSENSITIVE);
|
||||
|
||||
public static final Pattern VALIDATE_URL_REGEX =
|
||||
Pattern.compile("((http://|ftp://|https://|www.))(([a-zA-Z0-9\\._-]+\\.[a-zA-Z]{2,6})|([0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}))(:[0-9]{1,4})*(/[a-zA-Z0-9\\&%_\\./-~-]*)?");
|
||||
// public static final Pattern VALIDATE_URL_REGEX =
|
||||
// Pattern.compile("((http://|ftp://|https://|www.))(([a-zA-Z0-9\\._-]+\\.[a-zA-Z]{2,6})|([0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}))(:[0-9]{1,4})*(/[a-zA-Z0-9\\&%_\\./-~-]*)?");
|
||||
|
||||
public static boolean isEmailAddress(String emailStr) {
|
||||
Matcher matcher = VALID_EMAIL_ADDRESS_REGEX.matcher(emailStr);
|
||||
Matcher matcher = Patterns.EMAIL_ADDRESS.matcher(emailStr);
|
||||
return matcher.matches();
|
||||
}
|
||||
|
||||
public static boolean isUrlAddress(String url) {
|
||||
Matcher matcher = VALIDATE_URL_REGEX.matcher(url);
|
||||
Matcher matcher = Patterns.WEB_URL.matcher(url);
|
||||
return matcher.matches();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user