How to Validation phone number and -

前端 未结 5 2028
星月不相逢
星月不相逢 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:15

    Obj-C has NSPredicate for this. As I remember, you can use code like this for your task:

    NSPredicate * Pred = [NSPredicate predicateWithFormat:@"SELF MATCHES '^\+(?:[0-9] ?){6,14}[0-9]$'"];    
    bool ifYes = [Pred evaluateWithObject:_yourNSString]];
    

    for more detail look in Apple docs.

    If you want to found proper reg.exp., please use some libs like: http://regexlib.com/DisplayPatterns.aspx?cattabindex=6&categoryId=7

提交回复
热议问题