手机号码类型判断[2011-11-17更新]

/// <summary>
/// 手机号码类型判断
/// </summary>
/// <param name="mobile">手机号码</param>
/// <returns>
/// 返回值:
///     1   移动手机号码
///     2   联通手机号码
///     3   电信手机号码
///     4   固定电话、小灵通
///     0   未知
/// </returns>
static int CardType(string mobile)
{
    //移动电话
    if (Regex.IsMatch(mobile, @"^\d{11}$") && mobile.Substring(0, 1) != "0")
    {
        switch (mobile.Substring(0, 3))
        {
            case "134":
            case "135":
            case "136":
            case "137":
            case "138":
            case "139":
            case "147"://3g,数据卡
            case "150":
            case "151":
            case "152":
            case "157"://3g
            case "158":
            case "159":
            case "182":
            case "183":
            case "187"://3g
            case "188"://3g
                return 1;
            case "130":
            case "131":
            case "132":
            case "145"://3g,数据卡
            case "155":
            case "156":
            case "185"://3g,预留
            case "186"://3g
                return 2;
            case "133":
            case "153":
            case "180"://3g
            case "189"://3g
                return 3;
            default:
                return 0;

        }
    }
    //固定电话
    else if (Regex.IsMatch(mobile, @"^\d{3,4}-{0,1}\d{7,8}$"))
        return 4;
    //未知
    else
        return 0;
}

说明:由于普通手机号码可到营业厅不换号,换张新手机卡即可升级为3G,所以不能单纯从号码来判断用户属于2G还是3G!

移动、联通和电信最新号段

移动:134、135、136、137、138、139、147(3g,数据卡)、150、151、152、157(3g)、158、159、182、183、187(3g)、188(3g)
联通:130、131、132、145(3g,数据卡)、155、156、185(3g,预留)、186(3g)
电信:133、153、180(3g)、189(3g)

评论: 0 | 引用: 0 | 查看次数: 4518
发表评论
登录后再发表评论!