iOS手机号码 344 格式
//手机号码344格式
+(NSString*)phoneNumFommat:(NSString*)phoneNum{
NSString *tenDigitNumber = [phoneNum stringByReplacingOccurrencesOfString:@" " withString:@""];
if (tenDigitNumber.length > 11) {
tenDigitNumber = [tenDigitNumber substringToIndex:11];
}
if (tenDigitNumber.length > 7) {
tenDigitNumber = [tenDigitNumber stringByReplacingOccurrencesOfString:[NSString stringWithFormat:@"(\\d{3})(\\d{4})(\\d{%lu})",(tenDigitNumber.length - 7)]
withString:@"$1 $2 $3"
options:NSRegularExpressionSearch
range:NSMakeRange(0, [tenDigitNumber length])];
}else if (tenDigitNumber.length > 3){
tenDigitNumber = [tenDigitNumber stringByReplacingOccurrencesOfString:[NSString stringWithFormat:@"(\\d{3})(\\d{%lu})",(tenDigitNumber.length - 3)]
withString:@"$1 $2"
options:NSRegularExpressionSearch
range:NSMakeRange(0, [tenDigitNumber length])];
}
return tenDigitNumber;
}