How to Validation phone number and -

前端 未结 5 2029
星月不相逢
星月不相逢 2021-01-14 23:26

For the validation for the phone number and included -

@\"^\\+(?:[0-9] ?){6,14}[0-9]$\"

I have to validate phone number with -

example 333-333-3333 (

5条回答
  •  遥遥无期
    2021-01-15 00:13

    //phone no format:(000)000-0000

    -(BOOL)numberValidation:(NSString*)phoneString
    {
    
        NSString *phoneRegEx = @"\\([0-9]{3}\\)[0-9]{3}\\-[0-9]{4}";
    
        NSPredicate *phoneTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", phoneRegEx];
    
        BOOL result=[phoneTest evaluateWithObject:phoneString];
       return result;
    
    }
    

提交回复
热议问题