字符串相关
- 数字每隔3位用“,”隔开
NSNumberFormatter * formatter = [[NSNumberFormatter alloc] init];
formatter.positiveFormat = @"###,###";
return [formatter stringFromNumber:[NSNumber numberWithString:str]];
- 字符串自己数计算(包括中文、韩文等双字节字符)
NSString * str = @"[^\\x00-\\xff]";
NSString * result = [string stringByReplacingOccurrencesOfString:str withString:@"**" options:NSRegularExpressionSearch range:NSMakeRange(0, string.length)];
NSData * data = [result dataUsingEncoding:NSUTF8StringEncoding];
return data.length;