Possible Duplicate:
A comprehensive regex for phone number validation
How to validate a phone number (NSString *) in objective-c? Rules:
- minimum 7 digits
- maximum 10 digits
- the first digit must be 2, 3, 5, 6, 8 or 9
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use a regular expressions library (like RegexKit, etc), or you could use regular expressions through
NSPredicate(a bit more obscure, but doesn’t require third-party libraries). That would look something like this:If you’re on iPhone, then iOS 4 introduced
NSRegularExpression, which would also work. TheNSPredicateapproach works on both Mac and iPhone (any version).