iOS-过滤特殊字符

通讯录复制过来的手机号为13位,含2位特殊字符

//过滤特殊字符
NSCharacterSet *setToRemove = [[ NSCharacterSet characterSetWithCharactersInString:@"0123456789"]invertedSet];
NSString *ph = [[phoneStr componentsSeparatedByCharactersInSet:setToRemove]componentsJoinedByString:@""];

你可能感兴趣的:(iOS-过滤特殊字符)