身份证号码处理,前3后4中间以*拼接,返回处理好的字符串

2016-10-03  本文已影响43人  呦嚯嚯嚯12138

- (NSString *)ittemDisposeIdcardNumber:(NSString *)idcardNumber {

//星号字符串

NSString *xinghaoStr = @"";

//动态计算星号的个数

for (int i  = 0; i < idcardNumber.length - 7; i++) {

xinghaoStr = [xinghaoStr stringByAppendingString:@"*"];

}

//身份证号取前3后四中间以星号拼接

idcardNumber = [NSString stringWithFormat:@"%@%@%@",[idcardNumber substringToIndex:3],xinghaoStr,[idcardNumber substringFromIndex:idcardNumber.length-4]];

//返回处理好的身份证号

return idcardNumber;

}

上一篇下一篇

猜你喜欢

热点阅读