java-Regular expression to determine the phone number
It is not enough to match the phone number to a more accurate 11-digit number, for example, there is no number segment starting with 144,
Therefore, we must first clarify how many number segments have been opened now, and the country number segment is allocated as follows:
Mobile: 134, 135, 136, 137, 138, 139, 150, 151, 157 (TD), 158, 159, 187, 188
Unicom: 130, 131, 132, 152, 155, 156, 185, 186
Telecom: 133, 153, 180, 189, (1349 Wei Tong)
So now it's time to have a regular match test,
public static Boolean Ismobileno (String mobiles) { Pattern p = pattern.compile ("^ (13[0-9]) | ( 15[^4,\\D]) | (18[0,5-9])) \\d{8}$ "); Matcher m = p.matcher (mobiles); return m.matches ();
The second method:
String value= "phone number"; String regExp = "^[1" ([3][0-9]{1}|59|58|88|89) [0-9]{8}$]; Pattern p = pattern.compile (REGEXP); Matcher m = p.matcher (value); return M.find ();//boolean
java-Regular expression judgment zip code
China postcode is 6 digits, first digit is not 0
String str = "^[1-9][0-9]{5}$"; /** * code * @param paramstring * @return * * /public static Boolean Iszipno (String zipstring) { String str = "^[1-9][0-9]{5}$"; return Pattern.compile (str). Matcher (zipstring). matches ();
java-Regular expressions to determine if an email address is legitimate
/** * Determine if the mailbox is legal * @param Email * @return * * Public static Boolean isemail (String email) { if ( Null==email | | ". Equals (email)) return false; Pattern p = pattern.compile ("\\[email protected" (\\w+.) +[a-z]{2,3} "); Simple match Pattern p = pattern.compile ("\\w+ ([-+.] \\w+) *@\\w+ ([-.] \\w+) *\\.\\w+ ([-.] \\w+) * ");//Complex match Matcher m = p.matcher (email); return m.matches ();
Android Judge mobile phone number, zip code, email address, is correct