1, mobile phone number has become the recommended choice of various types of app accounts, but this will also involve the verification of mobile phone numbers,
As a result of the addition of the 170 segment this year, many of the current categories do not provide this, so it can only be modified
Not much to say direct sticker code:
/** * Mobile phone Number Verification * * @param mobile * * @return*/+ (BOOL) Validatemobile: (NSString *) mobile{//phone number starts with 13, 15, 18, eight \d numeric charactersNSString *phoneregex =@"^ ((13[0-9)) | ( 15[^4,\\D]) | (18[0,0-9])) \\d{8}$"; Nspredicate*phonetest = [Nspredicate predicatewithformat:@"Self MATCHES%@", Phoneregex]; BOOL result=[Phonetest Evaluatewithobject:mobile]; NSLog (@"result =%d", result); returnresult;}
^ ((13[0-9]) | (15[^4,\\d]) | (18[0,0-9])) \\D{8} key code, so just add a 170 verification to it.
/** * Mobile phone Number Verification * * @param mobile * * @return*/+ (BOOL) Validatemobile: (NSString *) mobile{//phone number starts with 13, 15, 18, eight \d numeric charactersNSString *phoneregex =@"^ ((13[0-9)) | ( 15[^4,\\D]) | (18[0,0-9]) | (170)) \\d{8}$"; Nspredicate*phonetest = [Nspredicate predicatewithformat:@"Self MATCHES%@", Phoneregex]; BOOL result=[Phonetest Evaluatewithobject:mobile]; NSLog (@"result =%d", result); returnresult;}
Mobile phone number verification (regular)