I have a many strings, here 3 for example:
1. example old
14. example new
234. example 45
I want to exclude the first numbers and make that:
example old
example new
example 45
What i do is:
NSString *fixed1 = [str substringWithRange:NSMakeRange(3, [str length]-3)];
NSString *fixedStr = [fixed1 stringByReplacingOccurrencesOfString:@". " withString:@""];
And what i got is:
example old
example new
example 45
The problem is the space at the start of “example new”. I don’t know how to remove it, if i try this:
NSString *fixed1 = [str substringWithRange:NSMakeRange(3, [str length]-3)];
NSString *fixed2 = [fixed1 stringByReplacingOccurrencesOfString:@". " withString:@""];
NSString *fixedStr = [fixed2 stringByReplacingOccurrencesOfString:@" " withString:@""];
I got this:
exampleold
examplenew
example45
Im going crazy with this, please someone have a nice & simple idea how to solve it?
Thanks!
You can use
with
[NSCharacterSet whitespaceCharacterSet]as a parameter to shave off spaces at the beginning and the end.