EDIT . I read the question again and saw that you want to confirm, not select the phone number, so I moved the section to NSDataDetector .
You can use NSDataDetector (which is a specialized subclass of NSRegularExpression ) to search for phone numbers in NSString (in my opinion, this uses the default iPhone default phone number algorithm).
NSDataDetector *detector = [NSDataDetector dataDetectorWithTypes:NSTextCheckingTypePhoneNumber error:&error]; NSUInteger numberOfMatches = [detector numberOfMatchesInString:string options:0 range:NSMakeRange(0, [string length])];
If you use a UITextView (but probably not a UITextField , as you are using here), you can allocate a phone number using the iPhone default phone number algorithm by setting its dataDetectorTypes property:
textView.dataDetectorTypes = UIDataDetectorTypePhoneNumber;
See UIDataDetectorTypes for other types of data detectors.
source share