数字1234567输出成1,234,567样式

NSError* error =NULL;

    NSRegularExpression * regex = [NSRegularExpression regularExpressionWithPattern:@"(\\d)(?=((\\d{3})+$))" options:NSRegularExpressionAllowCommentsAndWhitespace error:&error];


    NSMutableString * orgStr =[[NSMutableString alloc]initWithString:@"1234567"];


    NSString * needStr = [regex stringByReplacingMatchesInString:orgStr options:NSMatchingReportProgress range:NSMakeRange(0, orgStr.length) withTemplate:@"$1,"];

    NSSLog(@"输出看下 needStr:%@",needStr);

你可能感兴趣的:(数字1234567输出成1,234,567样式)