.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
网友评论