I won’t say much nonsense, I will just post java code to you. The code has been commented on and it is not well written. Please take care of it.
The code looks like this:
package com.alibaba.uyuni.common.util;import java.util.Random;public class GeneratePassword {/*** Generate random password* @param pwd_len* Total length of generated password* @return Password string*/public static String genRandomNum(int pwd_len) {// 26*2 letters + 10 numbers final int maxNum = 62;int i; // Generate random number int count = 0; // Length of generated password char[] str = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K','L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };StringBuffer pwd = new StringBuffer("");Random r = new Random();while (count < pwd_len) {// Generate random numbers, take absolute values, and prevent negative numbers from being generated, i = Math.abs(r.nextInt(maxNum)); // The maximum generated number is 62-1if (i >= 0 && i < str.length) {pwd.append(str[i]);count++;}}return pwd.toString();}public static void main(String[] args) {System.out.println(genRandomNum(6));// }}package com.alibaba.uyuni.common.util;import java.util.regex.Matcher;import java.util.regex.Pattern;public class RegexUtils {/*** Verify Email* @param email email address, format: [email protected], [email protected], xxx represents the email service provider* @return Verify returns true, and verification fails to return false*/ public static boolean checkEmail(String email) { String regex = "//w+@//w+//.[az]+(//.[az]+)?"; return Pattern.matches(regex, email); } /*** Verification *** number* @param idCard Resident *** number 15 or 18 digits, the last digit may be a number or letter* @return Return true for successful verification, and false for failure verification*/ public static boolean checkIdCard(String idCard) { String regex = "[1-9]//d{13,16}[a-zA-Z0-9]{1}"; return Pattern.matches(regex,idCard); } /*** Verify mobile phone number (supports international format, +86135xxxx... (Mainland China), +00852137xxxx... (Hong Kong, China))* @param mobile Number segments of mobile, China Unicom, and telecom operators*<p>Mobile number segments: 134(0-8), 135, 136, 137, 138, 139, 147 (predicted for TD network card)*, 150, 151, 152, 157 (TD dedicated), 158, 159, 187 (not enabled), 188 (TD dedicated)</p>*<p>China Unicom number segments: 130, 131, 132, 155, 156 (World Wind dedicated), 185 (not enabled), 186 (3g)</p>*<p>Telecom number segments: 133, 153, 180 (not enabled), 189</p>* @return Verification is successful and returns true, and verification is failed and returns false*/ public static boolean checkMobile(String mobile) { String regex = "(//+//d+)?1[3458]//d{9}$"; return Pattern.matches(regex,mobile); } /*** Verify the landline number* @param phone number, format: country (region) phone code + area code (city code) + phone number, such as: +8602085588447* <p><b>Country (region) Code:</b>Standard country (region) code that identifies the country (region) of the phone number. It contains one or more digits from 0 to 9, followed by a space-separated country code. </p>* <p><b> Area Code (City Code):</b>This may contain one or more numbers from 0 to 9, and the region or city code is placed in parentheses -* This component is omitted for countries (regions) that do not use the region or city code. </p>* <p><b>Phone number:</b>This contains one or more numbers from 0 to 9</p>* @return Return true when the verification is successful, and returns false*/ public static boolean checkPhone(String phone) { String regex = "(//+//d+)?(//d{3,4}//-?)?//d{7,8}$"; return Pattern.matches(regex, phone); } /*** Verify integers (positive integers and negative integers)* @param digit Integers between one or more bits 0-9* @return Return true when the verification is successful, returns false*/ public static boolean checkDigit(String digit) { String regex = "//-?[1-9]//d+"; return Pattern.matches(regex,digit); } /*** Verify integers and floating-point numbers (positive and negative integers and positive and negative floating-point numbers)* @param decimals Floating-point numbers between one or more bits 0-9, such as: 1.23, 233.30* @return Verify returns true, and fails to verify, and return false*/ public static boolean checkDecimals(String decimals) { String regex = "//-?[1-9]//d+(//.//d+)?"; return Pattern.matches(regex,decimals); } /*** Verify whitespace characters* @param blankSpace Whitespace characters, including: space, /t, /n, /r, /f, /x0B* @return Return true for successful verification, return false, fail to verify, return false*/ public static boolean checkBlankSpace(String blankSpace) { String regex = "//s+"; return Pattern.matches(regex,blankSpace); } /*** Verify Chinese* @param chinese Chinese characters* @return Return true for successful verification, return false*/ public static boolean checkChinese(String chinese) { String regex = "^[/u4E00-/u9FA5]+$"; return Pattern.matches(regex,chinese); } /*** Verification date (year, month, day)* @param birthday date, format: 1992-09-03, or 1992.09.03* @return Verification returns true, verification fails to return false*/ public static boolean checkBirthday(String birthday) { String regex = "[1-9]{4}([-./])//d{1,2}//1//d{1,2}"; return Pattern.matches(regex,birthday); } /*** Verification URL address* @param url Format: http://blog.csdn.net:80/xyang81/article/details/7705960? or http://www.csdn.net:80* @return Return true when the verification is successful, and false when the verification fails, public static boolean checkURL(String url) { String regex = "(https?://(w{3}//.)?)?//w+//.//w+(//.[a-zA-Z]+)*(://d{1,5})?(///w*)*(//??(.+=.*)?(&.+=.*)?)?"; return Pattern.matches(regex, url); } /*** <pre>* Get the first-level domain name of the URL URL* http://www.zuidaima.com/share/1550463379442688.htm ->> zuidaima.com* </pre>* * @param url* @return*/public static String getDomain(String url) {Pattern p = Pattern.compile("(?<=http://|//.)[^.]*?//.(com|cn|net|org|biz|info|cc|tv)", Pattern.CASE_INSENSITIVE);// Get the complete domain name // Pattern p=Pattern.compile("[^//]*?//.(com|cn|net|org|biz|info|cc|tv)", Pattern.CASE_INSENSITIVE);Matcher matcher = p.matcher(url);matcher.find();return matcher.group();}/*** Match Chinese postcode* @param postcode Postcode* @return Verification is successful and returns true, and verification is failed and false*/ public static boolean checkPostcode(String postcode) { String regex = "[1-9]//d{5}"; return Pattern.matches(regex, postcode); } /*** Match IP address (simple match, format, such as: 192.168.1.1, 127.0.0.1, no matching size of the IP segment)* @param ipAddress IPv4 standard address* @return Verification is returned true, verification is failed, verification is returned false*/ public static boolean checkIpAddress(String ipAddress) { String regex = "[1-9](//d{1,2})?//.(0|([1-9](//d{1,2})?))//.(0|([1-9](//d{1,2})?))//.(0|([1-9](//d{1,2})?))//.(0|([1-9](//d{1,2})?))"; return Pattern.matches(regex, ipAddress); } }The above is the relevant content that the editor has shared with you about the generation of Java random passwords and matching them with your email and mobile phones. I hope it will be helpful to you.