这是一个字符串
"Level1, Row 1, Gold, Seat no 7". "Level1, Row 1, Gold, Seat no 8". Name: Karan.
我正在尝试使这个字符串像这样
Level1, Row 1, Gold, Seat no 7, Level1, Row 1, Gold, Seat no 8, Name: Karan
我必须在此搜索座位号和名称,在此之前我需要将其分隔为数组。这是我正在尝试的方式。
[outStr stringByReplacingOccurrencesOfString:@"." withString:@","];
//[outStr stringByReplacingOccurrencesOfString:@"\"" withString:@""];
NSLog(@"outstr:%@", outStr);
NSArray *arrSplit1 = [outStr componentsSeparatedByString:@","];
NSString *stringToSearch = @"seat no";
NSString *stringToSearch1 = @"name";
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF contains[c] %@",stringToSearch];
NSPredicate *predicate1 = [NSPredicate predicateWithFormat:@"SELF contains[c] %@",stringToSearch1];
NSArray *results = [arrSplit1 filteredArrayUsingPredicate:predicate];
NSArray *results1 = [arrSplit1 filteredArrayUsingPredicate:predicate1];
NSLog(@"results:%@", results);
NSLog(@"results:%@", results1);
我怎样才能做到这一点,请指导。