I have on NSString
like this I want read only (I am here) this part how can I do ,I am here is one variable
[[["OK'","ok'","","OK'",0]],,"AB",,[["hello'",[1],YES,YES,100,0,4,0]],[["ok '",1,[["okidoki '",100,yes,yes]],[[0,3]],"okdoki'"]],,[,"I am here",[4]],[["AB"]],3]
Try this code. With regrular expression we parse substring in []. After split string by ,
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"\\[(.*?)\\]" options:NSRegularExpressionCaseInsensitive error:NULL];
NSString *test = @"[[[\"OK\",\"ok\",\"\",\"OK\",0]],,\"AB\",,[[\"hello\",[1],YES,YES,100,0,4,0]],[[\"ok\",1,[[\"okidoki\",100,yes,yes]],[[0,3]],\"okdoki\"]],,[,\"I am here\",[4]],[[\"AB\"]],3]";
NSString *input = test;
NSArray *myArray = [regex matchesInString:input options:0 range:NSMakeRange(0, [input length])] ;
NSMutableArray *matches = [NSMutableArray arrayWithCapacity:[myArray count]];
NSRange matchRange = [myArray[4] rangeAtIndex:1];
[matches addObject:[input substringWithRange:matchRange]];
NSString *elementString = [matches lastObject];
NSArray *listItems = [elementString componentsSeparatedByString:@","];
NSLog(@"I'm here: %@", listItems[1]);