Android Judge mobile phone number, zip code, email address, is correct

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.