There are not many things, but the general projects are enough.
public class RegularUtil { //ID card public static final String REGEX_ID_CARD = "^[1-9]\\d{5}[1-9]\\d{3}((0\\d)|(1[0-2]))(([0|1|2]\\d)|3[0-1])\\d{3}([0-9]|X)$"; //Verify the email address 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,}$"; //Phone number public static final String REGEX_PHONE = "0?(13|14|15|17|18)[0-9]{9}"; //Chinese character public static final String REGEX_TRUENAME = "^[\\u4e00-\\u9fa5]*$"; //bank card public static final String BANKNUMBER="^([0-9]{16}|[0-9]{19})$"; //Land-line telephone public static final String TELE= "([0-9]{3,4}-)?[0-9]{7,8}"; //Password strength verification public static final String REGEX_PWS="^(((?=.*[0-9])(?=.*[a-zA-Z])|(?=.*[0-9])(?=.*[^\\s0-9a-zA-Z])|(?=.*[a-zA-Z])(?=.*[^\\s0-9a-zA-Z]))[^\\s]+)$"; public static boolean isPhone(String mobiles){ if ((mobiles)){ return false; }else{ return (REGEX_PHONE); } } public static boolean isTel(String mobiles) { if ((mobiles)) { return false; } else { return (TELE); } } public static boolean isIDacard(String idcard){ if ((idcard)) return false; else return (REGEX_ID_CARD); } public static boolean isBankCard(String bankcard){ if ((bankcard)) return false; else return (BANKNUMBER); } public static boolean isEmail(String email){ if ((email)) return false; else return (REGEX_EMAIL); } public static boolean isTrueName(String name){ if ((name)) return false; else return (REGEX_TRUENAME); } //Verify password strength public static boolean isPsw(String psw) { //Contains at least two of them, including numbers, letters, and special symbols. if ((psw)) { return false; } else { //Limited length if(()<6||()>16){ return false; } //matches(): Whether the string matches the given regular expression return (REGEX_PWS); } } }
Summarize
The above is the commonly used regular expression verification tool class (example code) introduced to you by the editor. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. Thank you very much for your support for my website!