. h file
[OBJC] view plain copy
<span style= "FONT-SIZE:18PX;" > /**
* Turn into an asterisk tool
*/
@interface Asterisktool:nsobject
//Turn the phone number 第4-7位 into an asterisk
+ (nsstring *) Phonenumtoasterisk: (nsstring*) Phonenum;
//Turn the phone number 第5-14位 into an asterisk
+ (nsstring *) Idcardtoasterisk: (nsstring *) Idcardnum;
@end
. m file
[OBJC] view plain copy
<span style= "FONT-SIZE:18PX;" > @implementation Asterisktool
+ (nsstring *) Phonenumtoasterisk: (nsstring*) Phonenum
{
return [phonenum stringbyreplacingcharactersinrange: Nsmakerange (3,4 ) withstring:@ "* * *"];
}
+ (nsstring*) Idcardtoasterisk: (nsstring *) Idcardnum
{
return [idcardnum stringbyreplacingcharactersinrange: Nsmakerange (4, 10) withstring:@ "**********"];
}
@end
This was replaced with a nsstring,
This article from "zhuoking" blog, reproduced please contact the author!
Cell phone number in the middle with an asterisk