Phone Number Format for iPhone

I need to make programs programmatically in my iPhone application. I have a set of numbers in different countries with different formats - curly braces, periods, spaces, the "+" sign.

Is it possible to simply remove all this and leave only numbers?

eg:

+ 1- (609) 452-8401 => 16094528401 // usa
+49 (0) 89.439 => 49089439 // germany
+ 1- (949) 586-1250 => 19495861250 // los angeles, usa

Will it be right?

+4
source share
1 answer

try the following: -

NSMutableString *str1=[[NSMutableString alloc] initWithString:telephoneString]; [str1 setString:[str1 stringByReplacingOccurrencesOfString:@"(" withString:@""]]; [str1 setString:[str1 stringByReplacingOccurrencesOfString:@")" withString:@""]]; [str1 setString:[str1 stringByReplacingOccurrencesOfString:@"-" withString:@""]]; [str1 setString:[str1 stringByReplacingOccurrencesOfString:@" " withString:@""]]; telephoneString = [@"tel://" stringByAppendingString:str1]; [str1 release]; [[UIApplication sharedApplication] openURL:[NSURL URLWithString:telephoneString]]; 
+3
source

All Articles