Method 1: Remove the numbers from the string
#import<Foundation/Foundation.h>intMainintargcConst Char*argv[]) {@autoreleasepool {nsstring*stroriginal=@"123-456-789-000"; Nsrange rang1={0,3},rang2={4,3},rang3={8,3},rang4={ A,3}; NSString*str1=[stroriginal substringwithrange:rang1]; NSString*str2=[stroriginal substringwithrange:rang2]; NSString*str3=[stroriginal Substringwithrange:rang3]; NSString*str4=[stroriginal Substringwithrange:rang4]; NSString*strresult=[[nsstring Alloc]initwithformat:@"%@%@%@%@", STR1,STR2,STR3,STR4]; NSLog (@"%@ have been change to%@", Stroriginal,strresult); } return 0;}
Method 2: Delete the "-" in the string
#import<Foundation/Foundation.h>intMainintargcConst Char*argv[]) {@autoreleasepool {nsmutablestring*string=[[nsmutablestring Alloc]initwithformat:@"123-456-789-000"]; Nsrange rang=[stringRangeofstring:@"-"]; Do{ [stringDeletecharactersinrange:rang]; Rang=[stringRangeofstring:@"-"]; } while(rang.location!=nsnotfound); NSLog (@"string after chang:%@",string); } return 0;}
NSString Job 2: Take out the numeric portion of the string "123-456-789-000" to form a new string output