Java Judge mobile phone number operator

Source: Internet
Author: User
Package com.cafintech.assembly.entity;

Import Com.alibaba.fastjson.JSONObject;
 /** * Created by 15600 on 2017/8/7. * * public class Judgeoperator {/* 1, mobile number 134,135,136,137, 138,139,147,150,151, 152,157,158,159,178,182,183,184,18
    7,188.
    2, China Unicom number of 130,131,132,155,156,185,186,145,176.
    3, the electrical signal section has 133,153,177.173,180,181,189. */static String YD = "^[1]{1}" ([3]{1}[4-9]{1}) | ( [5] {1} [012789] {1}) | ([8]{1}[23478]{1}) | ([4]{1}[7]{1}) | ([7]{1}[8]{1})] [0-9]
    {8}$ "; static String LT = "^[1]{1}" ([3]{1}[0-2]{1}) | ( [5] {1} [56] {1}) | ([8]{1}[56]{1}) | ([4]{1}[5]{1}) | ([7]{1}[6]{1})] [0-9]
    {8}$ "; static String DX = "^[1]{1}" ([3]{1}[3]{1}) | ( [5] {1} [3] {1}) | ([8]{1}[09]{1}) | ([7]{1}[37]{1})] [0-9]

    {8}$ "; Public Judgeoperator () {} public static string Matchnum (String mobphnnum) {/** * entry: Mobile phone number *re Turn param * Code (INT): 200 phone number meets the requirements code:500 mobile phone number is not required * type (int): 1:yd 2:lt 3:dx/J
        Sonobject jsonobject=new jsonobject (); // Determine if the mobile phone number is 11-bit if (mobphnnum.length () = = 11) {//Determine if the phone number is in line with China Mobile's number rule if (mobphnnum.matches (YD))
                {Jsonobject.put ("code", 200);
            Jsonobject.put ("type", 1); //Determine if the mobile phone number is in accordance with China Unicom number rule else if (mobphnnum.matches (LT)) {jsonobject.put ("code", 2
                00);
            Jsonobject.put ("type", 2); //Determine if the phone number is in line with China Telecom's number rule else if (mobphnnum.matches (DX)) {jsonobject.put ("code", 2
                00);
            Jsonobject.put ("type", 3);
            }//is not suitable for unknown else {jsonobject.put ("code", 500);
        }//Not 11-bit else {jsonobject.put ("code", 500);
    return jsonobject.tostring ();
 }
}

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.