Cocoa - Remove All Chars Before and Including Substring from String
getting myself confused with NSString's various range metho开发者_如何学编程ds and where and when they should be used.
I have a random string. Somewhere in the string it may (or may not) contain an identifier such as "Customer Name:" (the quotes will not be included.)
Problem: I need a new string where everything up to and including "Customer Name:" has been removed from the original string.
Any advice is appreciated.
Mac OS X 10.4 compatibility required, manual GC.
NSRange range = [str rangeOfString:@"Customer Name:"];
NSString *newStr = [str substringFromIndex:range.location + range.length];
精彩评论