+(NSString *)getNewBankNumWitOldBankNum:(NSString *)bankNum
{
NSMutableString *mutableStr;
if (bankNum.length) {
mutableStr = [NSMutableString stringWithString:bankNum];
for (int i = 0 ; i < mutableStr.length; i ++) {
if (i>2&&i<mutableStr.length - 3) {
[mutableStr replaceCharactersInRange:NSMakeRange(i, 1) withString:@"*"];
}
}
NSString *text = mutableStr;
NSCharacterSet *characterSet = [NSCharacterSet characterSetWithCharactersInString:@"0123456789\b"];
text = [text stringByReplacingOccurrencesOfString:@" " withString:@""];
NSString *newString = @"";
while (text.length > 0) {
NSString *subString = [text substringToIndex:MIN(text.length, 4)];
newString = [newString stringByAppendingString:subString];
if (subString.length == 4) {
newString = [newString stringByAppendingString:@" "];
}
text = [text substringFromIndex:MIN(text.length, 4)];
}
newString = [newString stringByTrimmingCharactersInSet:[characterSet invertedSet]];
return newString;
}
return bankNum;
}
转载于:https://www.cnblogs.com/chaicla-ios/p/6742080.html