Remove Character set form string:
NSString *strPhone = @"54564-6556-6-65(113)";
NSCharacterSet *charactersToRemove =[[NSCharacterSet characterSetWithCharactersInString:@"0123456789"] invertedSet];
strPhone = [[strPhone componentsSeparatedByCharactersInSet:charactersToRemove] componentsJoinedByString:@""];
NSLog(@"%@",strPhone);
Result : Get 545646556665113 by removing -,( and ) from string
NSString *strPhone = @"54564-6556-6-65(113)";
NSCharacterSet *charactersToRemove =[NSCharacterSet characterSetWithCharactersInString:@"0123456789"];
strPhone = [[strPhone componentsSeparatedByCharactersInSet:charactersToRemove] componentsJoinedByString:@""];
NSLog(@"%@",strPhone);
Result : Get --() by removing all entry of 0123456789
thanks
Happpppyyyyyyy Pro.....................
No comments:
Post a Comment