Find the index of a character in a string
U can find index of the character ")" like this:
NSString *Original=@"88) 12-sep-2012";
NSRange range = [Original rangeOfString:@")"];
if(range.location != NSNotFound)
{
NSString *result = [Original substringWithRange:NSMakeRange(0, range.location)];
}
You can use the following code to see the characters before ")"
// this would split the string into values which would be stored in an array
NSArray *splitStringArray = [yourString componentsSeparatedByString:@")"];
// this would display the characters before the character ")"
NSLog(@"%@", [splitStringArray objectAtIndex:0]);
To print the characters before the first right paren, you can do this:
NSString *str = [[yourString componentsSeparatedByString:@")"] objectAtIndex:0];
NSLog(@"%@", str);
// If you need the character index:
NSUInteger index = str.length;
NSUInteger index = [Original rangeOfString:@")"];
NSString *result = [Original substringWithRange:NSMakeRange(0, index)];