Java e-commerce common regular expression mobile phone number email ID verification code, etc.
Package cn.java.com;
Import Java.util.regex.Pattern;
/**
* Account-related attribute verification tool
*
*/
public class Verifyutil {
/**
* Regular expression: Verify user name
*/
public static final String regex_username = "^[a-za-z]\\w{5,20}$";
/**
* Regular expression: Verify password
*/
public static final String Regex_password = "^[a-za-z0-9]{6,20}$";
/**
* Regular expression: Verify the phone number
*/
public static final String regex_mobile = "^ ((17[0-9]) | ( 14[0-9]) | (13[0-9]) | (15[^4,\\d]) | (18[0,5-9])) \\d{8}$ ";
/**
* Regular expression: Verify Mailbox
*/
public static final String Regex_email = "^ ([a-z0-9a-z]+[-|\\.]?) +[a-z0-9a-z]@ ([a-z0-9a-z]+ (-[a-z0-9a-z]+) \ \.) +[a-za-z]{2,}$ ";
/**
* Regular Expressions: Validating Chinese characters
*/
public static final String Regex_chinese = "^[\u4e00-\u9fa5],{0,}$";
/**
* Regular expression: Verify ID
*/
public static final String Regex_id_card = "(^\\d{18}$) | (^\\d{15}$) ";
/**
* Regular expression: Verify URL
*/
public static final String Regex_url = "http (s)?:/ /([\\w-]+\\.) +[\\w-]+ (/[\\w-./?%&=]*)? ";
/**
* Regular expression: Verify IP Address
*/
public static final String regex_ip_addr = "(25[0-5]|2[0-4]\\d|[ 0-1]\\d{2}| [1-9]?\\d) ";
/**
* Verify user name
*
* @param username
* @return Checksum returns TRUE, otherwise false
*/
public static Boolean Isusername (String username) {
Return Pattern.matches (Regex_username, USERNAME);
}
/**
* Check Password
*
* @param password
* @return Checksum returns TRUE, otherwise false
*/
public static Boolean Ispassword (String password) {
Return Pattern.matches (Regex_password, PASSWORD);
}
/**
* Check the phone number
*
* @param Mobile
* @return Checksum returns TRUE, otherwise false
*/
public static Boolean IsMobile (String mobile) {
Return Pattern.matches (Regex_mobile, MOBILE);
}
/**
* Check Mailbox
*
* @param Email
* @return Checksum returns TRUE, otherwise false
*/
public static Boolean isemail (String email) {
Return Pattern.matches (Regex_email, EMAIL);
}
/**
* Check Kanji
*
* @param Chinese
* @return Checksum returns TRUE, otherwise false
*/
public static Boolean Ischinese (String Chinese) {
Return pattern.matches (Regex_chinese, Chinese);
}
/**
* Verify ID
*
* @param idcard
* @return Checksum returns TRUE, otherwise false
*/
public static Boolean Isidcard (String idcard) {
Return Pattern.matches (Regex_id_card, Idcard);
}
/**
* Check URL
*
* @param URL
* @return Checksum returns TRUE, otherwise false
*/
public static Boolean isurl (String URL) {
Return Pattern.matches (Regex_url, URL);
}
/**
* Verify IP Address
*
* @param ipaddr
* @return
*/
public static Boolean isipaddr (String ipaddr) {
Return Pattern.matches (REGEX_IP_ADDR, ipaddr);
}
}
Java e-commerce common regular expression mobile phone number email ID verification code, etc.