NSString *tenDigitNumber = @"5554449999";
tenDigitNumber = [tenDigitNumber stringByReplacingOccurrencesOfString:@"(\\d{3})(\\d{3})(\\d{4})"
withString:@"$1-$2-$3"
options:NSRegularExpressionSearch
range:NSMakeRange(0, [tenDigitNumber length])];
NSLog(@"%@", tenDigitNumber);
此为格式化334的形式,具体的其他格式可以修改正则表达式.
网友评论