I need to Remove some extra string that which coming in between the "(" ")" is this possible?. If so kindly tell me the way that need to do.
For example "Lead Programmer Ana开发者_开发问答lyst(#5641)". I need to remove the string #5641 that which is between ( and ).
Thank you, S.
pass Your string to the below method , it will return the proper string
- (NSString *)stringCleaner:(NSString *)yourString {
NSScanner *theScanner;
NSString *text = nil;
theScanner = [NSScanner scannerWithString:yourString];
while ([theScanner isAtEnd] == NO) {
[theScanner scanUpToString:@"(" intoString:NULL] ;
[theScanner scanUpToString:@")" intoString:&text] ;
yourString = [yourString stringByReplacingOccurrencesOfString:
[NSString stringWithFormat:@"%@)", text]
withString:@""];
}
return yourString;
}
精彩评论