//
NSString *idSStr = @"12345678901234567";
NSString *phoneStr = [self replaceStringWithAsterisk:idSStr startLocation:0 lenght:idSStr.length - 4 - 0];
XPFLog(@" phoneStr : %@", phoneStr);
=======================================================
//把字符串替换成星号
- (NSString*)replaceStringWithAsterisk:(NSString*)originalStr startLocation:(NSInteger)startLocation lenght:(NSInteger)lenght {
NSString*newStr = originalStr;
for(inti =0; i < lenght; i++) {
NSRangerange =NSMakeRange(startLocation,1);
newStr = [newStrstringByReplacingCharactersInRange:range withString:@"*"];
startLocation ++;
}
returnnewStr;
}
网友评论