Similar question to Recursive pattern in regex, but in Objective-C.
I want to find the ranges or substrings of outer brackets.
Example input:
NSString *input = @"{a {b c}} {d e}";
Example result:
// yeah, I know, we can't put NSRange in an array, it is just to illustrate
NSArray *matchesA = @[NSMakeRange(0, 9), NSMakeRange(10, 5)]; // OK
NSArray *matchesB = @[NSMakeRange(1, 7), NSMakeRange(11, 3)]; // OK too
NSArray *outputA = @[@"{a {b c}}", @"{d e}"]; // OK
NSArray *outputB = @[@"a {b c}", @"d e"]; // OK too
Unfortunately, NSRegularExpression does not accept ?R
apparently. Any alternative to match the outer brackets?