手机号、身份证号转星号
2020-06-15 本文已影响0人
zwing
.h文件
@interface AsteriskTool : NSObject
//把手机号第4-7位变成星号
+(NSString *)phoneNumToAsterisk:(NSString*)phoneNum;
//把身份证号第5-14位变成星号
+(NSString *)idCardNumToAsterisk:(NSString *)idCardNum;
@end
.m文件
@implementation AsteriskTool
+(NSString *)phoneNumToAsterisk:(NSString *)phoneNum
{
return [phoneNum stringByReplacingCharactersInRange:NSMakeRange(3, 4) withString:@"****"];
}
+(NSString *)idCardNumToAsterisk:(NSString *)idCardNum
{
return [idCardNum stringByReplacingCharactersInRange:NSMakeRange(4, 10) withString:@"**********"];
}
@end