phoneString __NSCFString * @"\U0000202d135 4567 6218\U0000202c" 0x00000001c005ce00
(lldb) po phoneString
135 4567 6218
(lldb) po phoneString.length
15
(lldb)
ios 11之后从电话簿复制粘贴会出现特殊不可见字符 需要处理
+ (NSString *)getSeparatedPhoneNumberWithString:(NSString *)phoneString {
NSCharacterSet *characterSet = [NSCharacterSet characterSetWithCharactersInString:@"0123456789"];
NSString * string = phoneString;
//invertedSet方法是去反字符,把所有的除了characterSet里的字符都找出来(包含去空格功能)
NSCharacterSet *specCharacterSet = [characterSet invertedSet];
NSArray * strArr = [string componentsSeparatedByCharactersInSet:specCharacterSet];
return [strArr componentsJoinedByString:@""];
}