zoukankan      html  css  js  c++  java
  • iOS 验证邮箱和手机 拨打电话

    //邮箱

    + (BOOL)checkEmail:(NSString *)email

    {

        NSString *emailRegex   = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}";

        NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex];

        return [emailTest evaluateWithObject:email];

    }

    //手机

    + (BOOL)checkPhoneNum:(NSString *)numStr

    {

        

        NSString * MOBILE            = @"^1(3[0-9]|5[0-35-9]|7[06-8]|8[0-9])\d{8}$";

        NSString * CM                = @"^1(34[0-8]|(3[5-9]|5[017-9]|78|8[2-478])\d)\d{7}$";

        NSString * CU                = @"^1(3[0-2]|5[256]|7[06]|8[56])\d{8}$";

        NSString * CT                = @"^1((33|53|77|8[019])[0-9]|349)\d{7}$";

        NSPredicate *regextestmobile = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", MOBILE];

        NSPredicate *regextestcm     = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", CM];

        NSPredicate *regextestcu     = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", CU];

        NSPredicate *regextestct     = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", CT];

        BOOL res1                    = [regextestmobile evaluateWithObject:numStr];

        BOOL res2                    = [regextestcm evaluateWithObject:numStr];

        BOOL res3                    = [regextestcu evaluateWithObject:numStr];

        BOOL res4                    = [regextestct evaluateWithObject:numStr];

        

        if (res1 || res2 || res3 || res4 )

        {

            return YES;

        }

        else

        {

            return NO;

        }

    }

    拨打电话

    number = @"13212341234";

    [[UIApplication sharedApplication]openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel://%@",number]]];

  • 相关阅读:
    Django之cookie与session
    Django之在Python中调用Django环境
    Django之Django终端打印SQL语句
    Django之事务
    Django之ORM操作(聚合 分组、F Q)
    Linux常用服务安装部署
    Linux服务基础命令
    程序员的vim
    Linux的xshell命令
    Linux操作服务器的初识
  • 原文地址:https://www.cnblogs.com/liaolijun/p/4797748.html
Copyright © 2011-2022 走看看