Objective-c – How to remove first 3 characters from NSString


I have a string like this "A. rahul VyAs"

and i want to remove "A. " and the space after the "A." so that new string would be "rahul VyAs"

How do i achieve this?

Best Solution

You can use the NSString instance methods substringWithRange: or substringFromIndex:

NSString *str = @"A. rahul VyAs";
NSString *newStr = [str substringWithRange:NSMakeRange(3, [str length]-3)];


NSString *str = @"A. rahul VyAs";
NSString *newStr = [str substringFromIndex:3];